bubblewrap_libglnx_submodule.patch 495 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536
  1. diff -Nuar flatpak-1.0.0.orig/bubblewrap/autogen.sh flatpak-1.0.0/bubblewrap/autogen.sh
  2. --- flatpak-1.0.0.orig/bubblewrap/autogen.sh 1970-01-01 02:00:00.000000000 +0200
  3. +++ flatpak-1.0.0/bubblewrap/autogen.sh 2018-02-03 21:26:06.272233339 +0300
  4. @@ -0,0 +1,19 @@
  5. +#!/bin/sh
  6. +
  7. +test -n "$srcdir" || srcdir=`dirname "$0"`
  8. +test -n "$srcdir" || srcdir=.
  9. +
  10. +olddir=`pwd`
  11. +cd $srcdir
  12. +
  13. +if ! (autoreconf --version >/dev/null 2>&1); then
  14. + echo "*** No autoreconf found, please install it ***"
  15. + exit 1
  16. +fi
  17. +
  18. +mkdir -p m4
  19. +
  20. +autoreconf --force --install --verbose
  21. +
  22. +cd $olddir
  23. +test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
  24. diff -Nuar flatpak-1.0.0.orig/bubblewrap/bind-mount.c flatpak-1.0.0/bubblewrap/bind-mount.c
  25. --- flatpak-1.0.0.orig/bubblewrap/bind-mount.c 1970-01-01 02:00:00.000000000 +0200
  26. +++ flatpak-1.0.0/bubblewrap/bind-mount.c 2018-02-03 21:26:06.272233339 +0300
  27. @@ -0,0 +1,440 @@
  28. +/* bubblewrap
  29. + * Copyright (C) 2016 Alexander Larsson
  30. + *
  31. + * This program is free software; you can redistribute it and/or
  32. + * modify it under the terms of the GNU Lesser General Public
  33. + * License as published by the Free Software Foundation; either
  34. + * version 2 of the License, or (at your option) any later version.
  35. + *
  36. + * This library is distributed in the hope that it will be useful,
  37. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  39. + * Lesser General Public License for more details.
  40. + *
  41. + * You should have received a copy of the GNU Lesser General Public
  42. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  43. + *
  44. + */
  45. +
  46. +#include "config.h"
  47. +
  48. +#include <sys/mount.h>
  49. +
  50. +#include "utils.h"
  51. +#include "bind-mount.h"
  52. +
  53. +static char *
  54. +skip_token (char *line, bool eat_whitespace)
  55. +{
  56. + while (*line != ' ' && *line != '\n')
  57. + line++;
  58. +
  59. + if (eat_whitespace && *line == ' ')
  60. + line++;
  61. +
  62. + return line;
  63. +}
  64. +
  65. +static char *
  66. +unescape_inline (char *escaped)
  67. +{
  68. + char *unescaped, *res;
  69. + const char *end;
  70. +
  71. + res = escaped;
  72. + end = escaped + strlen (escaped);
  73. +
  74. + unescaped = escaped;
  75. + while (escaped < end)
  76. + {
  77. + if (*escaped == '\\')
  78. + {
  79. + *unescaped++ =
  80. + ((escaped[1] - '0') << 6) |
  81. + ((escaped[2] - '0') << 3) |
  82. + ((escaped[3] - '0') << 0);
  83. + escaped += 4;
  84. + }
  85. + else
  86. + {
  87. + *unescaped++ = *escaped++;
  88. + }
  89. + }
  90. + *unescaped = 0;
  91. + return res;
  92. +}
  93. +
  94. +static bool
  95. +match_token (const char *token, const char *token_end, const char *str)
  96. +{
  97. + while (token != token_end && *token == *str)
  98. + {
  99. + token++;
  100. + str++;
  101. + }
  102. + if (token == token_end)
  103. + return *str == 0;
  104. +
  105. + return FALSE;
  106. +}
  107. +
  108. +static unsigned long
  109. +decode_mountoptions (const char *options)
  110. +{
  111. + const char *token, *end_token;
  112. + int i;
  113. + unsigned long flags = 0;
  114. + static const struct { int flag;
  115. + char *name;
  116. + } flags_data[] = {
  117. + { 0, "rw" },
  118. + { MS_RDONLY, "ro" },
  119. + { MS_NOSUID, "nosuid" },
  120. + { MS_NODEV, "nodev" },
  121. + { MS_NOEXEC, "noexec" },
  122. + { MS_NOATIME, "noatime" },
  123. + { MS_NODIRATIME, "nodiratime" },
  124. + { MS_RELATIME, "relatime" },
  125. + { 0, NULL }
  126. + };
  127. +
  128. + token = options;
  129. + do
  130. + {
  131. + end_token = strchr (token, ',');
  132. + if (end_token == NULL)
  133. + end_token = token + strlen (token);
  134. +
  135. + for (i = 0; flags_data[i].name != NULL; i++)
  136. + {
  137. + if (match_token (token, end_token, flags_data[i].name))
  138. + {
  139. + flags |= flags_data[i].flag;
  140. + break;
  141. + }
  142. + }
  143. +
  144. + if (*end_token != 0)
  145. + token = end_token + 1;
  146. + else
  147. + token = NULL;
  148. + }
  149. + while (token != NULL);
  150. +
  151. + return flags;
  152. +}
  153. +
  154. +typedef struct MountInfo MountInfo;
  155. +struct MountInfo {
  156. + char *mountpoint;
  157. + unsigned long options;
  158. +};
  159. +
  160. +typedef MountInfo *MountTab;
  161. +
  162. +static void
  163. +mount_tab_free (MountTab tab)
  164. +{
  165. + int i;
  166. +
  167. + for (i = 0; tab[i].mountpoint != NULL; i++)
  168. + free (tab[i].mountpoint);
  169. + free (tab);
  170. +}
  171. +
  172. +static inline void
  173. +cleanup_mount_tabp (void *p)
  174. +{
  175. + void **pp = (void **) p;
  176. +
  177. + if (*pp)
  178. + mount_tab_free ((MountTab)*pp);
  179. +}
  180. +
  181. +#define cleanup_mount_tab __attribute__((cleanup (cleanup_mount_tabp)))
  182. +
  183. +typedef struct MountInfoLine MountInfoLine;
  184. +struct MountInfoLine {
  185. + const char *mountpoint;
  186. + const char *options;
  187. + bool covered;
  188. + int id;
  189. + int parent_id;
  190. + MountInfoLine *first_child;
  191. + MountInfoLine *next_sibling;
  192. +};
  193. +
  194. +static unsigned int
  195. +count_lines (const char *data)
  196. +{
  197. + unsigned int count = 0;
  198. + const char *p = data;
  199. +
  200. + while (*p != 0)
  201. + {
  202. + if (*p == '\n')
  203. + count++;
  204. + p++;
  205. + }
  206. +
  207. + /* If missing final newline, add one */
  208. + if (p > data && *(p-1) != '\n')
  209. + count++;
  210. +
  211. + return count;
  212. +}
  213. +
  214. +static int
  215. +count_mounts (MountInfoLine *line)
  216. +{
  217. + MountInfoLine *child;
  218. + int res = 0;
  219. +
  220. + if (!line->covered)
  221. + res += 1;
  222. +
  223. + child = line->first_child;
  224. + while (child != NULL)
  225. + {
  226. + res += count_mounts (child);
  227. + child = child->next_sibling;
  228. + }
  229. +
  230. + return res;
  231. +}
  232. +
  233. +static MountInfo *
  234. +collect_mounts (MountInfo *info, MountInfoLine *line)
  235. +{
  236. + MountInfoLine *child;
  237. +
  238. + if (!line->covered)
  239. + {
  240. + info->mountpoint = xstrdup (line->mountpoint);
  241. + info->options = decode_mountoptions (line->options);
  242. + info ++;
  243. + }
  244. +
  245. + child = line->first_child;
  246. + while (child != NULL)
  247. + {
  248. + info = collect_mounts (info, child);
  249. + child = child->next_sibling;
  250. + }
  251. +
  252. + return info;
  253. +}
  254. +
  255. +static MountTab
  256. +parse_mountinfo (int proc_fd,
  257. + const char *root_mount)
  258. +{
  259. + cleanup_free char *mountinfo = NULL;
  260. + cleanup_free MountInfoLine *lines = NULL;
  261. + cleanup_free MountInfoLine **by_id = NULL;
  262. + cleanup_mount_tab MountTab mount_tab = NULL;
  263. + MountInfo *end_tab;
  264. + int n_mounts;
  265. + char *line;
  266. + int i;
  267. + int max_id;
  268. + unsigned int n_lines;
  269. + int root;
  270. +
  271. + mountinfo = load_file_at (proc_fd, "self/mountinfo");
  272. + if (mountinfo == NULL)
  273. + die_with_error ("Can't open /proc/self/mountinfo");
  274. +
  275. + n_lines = count_lines (mountinfo);
  276. + lines = xcalloc (n_lines * sizeof (MountInfoLine));
  277. +
  278. + max_id = 0;
  279. + line = mountinfo;
  280. + i = 0;
  281. + root = -1;
  282. + while (*line != 0)
  283. + {
  284. + int rc, consumed = 0;
  285. + unsigned int maj, min;
  286. + char *end;
  287. + char *rest;
  288. + char *mountpoint;
  289. + char *mountpoint_end;
  290. + char *options;
  291. + char *options_end;
  292. + char *next_line;
  293. +
  294. + assert (i < n_lines);
  295. +
  296. + end = strchr (line, '\n');
  297. + if (end != NULL)
  298. + {
  299. + *end = 0;
  300. + next_line = end + 1;
  301. + }
  302. + else
  303. + next_line = line + strlen (line);
  304. +
  305. + rc = sscanf (line, "%d %d %u:%u %n", &lines[i].id, &lines[i].parent_id, &maj, &min, &consumed);
  306. + if (rc != 4)
  307. + die ("Can't parse mountinfo line");
  308. + rest = line + consumed;
  309. +
  310. + rest = skip_token (rest, TRUE); /* mountroot */
  311. + mountpoint = rest;
  312. + rest = skip_token (rest, FALSE); /* mountpoint */
  313. + mountpoint_end = rest++;
  314. + options = rest;
  315. + rest = skip_token (rest, FALSE); /* vfs options */
  316. + options_end = rest;
  317. +
  318. + *mountpoint_end = 0;
  319. + lines[i].mountpoint = unescape_inline (mountpoint);
  320. +
  321. + *options_end = 0;
  322. + lines[i].options = options;
  323. +
  324. + if (lines[i].id > max_id)
  325. + max_id = lines[i].id;
  326. + if (lines[i].parent_id > max_id)
  327. + max_id = lines[i].parent_id;
  328. +
  329. + if (path_equal (lines[i].mountpoint, root_mount))
  330. + root = i;
  331. +
  332. + i++;
  333. + line = next_line;
  334. + }
  335. + assert (i == n_lines);
  336. +
  337. + if (root == -1)
  338. + {
  339. + mount_tab = xcalloc (sizeof (MountInfo) * (1));
  340. + return steal_pointer (&mount_tab);
  341. + }
  342. +
  343. + by_id = xcalloc ((max_id + 1) * sizeof (MountInfoLine*));
  344. + for (i = 0; i < n_lines; i++)
  345. + by_id[lines[i].id] = &lines[i];
  346. +
  347. + for (i = 0; i < n_lines; i++)
  348. + {
  349. + MountInfoLine *this = &lines[i];
  350. + MountInfoLine *parent = by_id[this->parent_id];
  351. + MountInfoLine **to_sibling;
  352. + MountInfoLine *sibling;
  353. + bool covered = FALSE;
  354. +
  355. + if (!has_path_prefix (this->mountpoint, root_mount))
  356. + continue;
  357. +
  358. + if (parent == NULL)
  359. + continue;
  360. +
  361. + if (strcmp (parent->mountpoint, this->mountpoint) == 0)
  362. + parent->covered = TRUE;
  363. +
  364. + to_sibling = &parent->first_child;
  365. + sibling = parent->first_child;
  366. + while (sibling != NULL)
  367. + {
  368. + /* If this mountpoint is a path prefix of the sibling,
  369. + * say this->mp=/foo/bar and sibling->mp=/foo, then it is
  370. + * covered by the sibling, and we drop it. */
  371. + if (has_path_prefix (this->mountpoint, sibling->mountpoint))
  372. + {
  373. + covered = TRUE;
  374. + break;
  375. + }
  376. +
  377. + /* If the sibling is a path prefix of this mount point,
  378. + * say this->mp=/foo and sibling->mp=/foo/bar, then the sibling
  379. + * is covered, and we drop it.
  380. + */
  381. + if (has_path_prefix (sibling->mountpoint, this->mountpoint))
  382. + *to_sibling = sibling->next_sibling;
  383. + else
  384. + to_sibling = &sibling->next_sibling;
  385. + sibling = sibling->next_sibling;
  386. + }
  387. +
  388. + if (covered)
  389. + continue;
  390. +
  391. + *to_sibling = this;
  392. + }
  393. +
  394. + n_mounts = count_mounts (&lines[root]);
  395. + mount_tab = xcalloc (sizeof (MountInfo) * (n_mounts + 1));
  396. +
  397. + end_tab = collect_mounts (&mount_tab[0], &lines[root]);
  398. + assert (end_tab == &mount_tab[n_mounts]);
  399. +
  400. + return steal_pointer (&mount_tab);
  401. +}
  402. +
  403. +int
  404. +bind_mount (int proc_fd,
  405. + const char *src,
  406. + const char *dest,
  407. + bind_option_t options)
  408. +{
  409. + bool readonly = (options & BIND_READONLY) != 0;
  410. + bool devices = (options & BIND_DEVICES) != 0;
  411. + bool recursive = (options & BIND_RECURSIVE) != 0;
  412. + unsigned long current_flags, new_flags;
  413. + cleanup_mount_tab MountTab mount_tab = NULL;
  414. + cleanup_free char *resolved_dest = NULL;
  415. + int i;
  416. +
  417. + if (src)
  418. + {
  419. + if (mount (src, dest, NULL, MS_MGC_VAL | MS_BIND | (recursive ? MS_REC : 0), NULL) != 0)
  420. + return 1;
  421. + }
  422. +
  423. + /* The mount operation will resolve any symlinks in the destination
  424. + path, so to find it in the mount table we need to do that too. */
  425. + resolved_dest = realpath (dest, NULL);
  426. + if (resolved_dest == NULL)
  427. + return 2;
  428. +
  429. + mount_tab = parse_mountinfo (proc_fd, resolved_dest);
  430. + if (mount_tab[0].mountpoint == NULL)
  431. + {
  432. + errno = EINVAL;
  433. + return 2; /* No mountpoint at dest */
  434. + }
  435. +
  436. + assert (path_equal (mount_tab[0].mountpoint, resolved_dest));
  437. + current_flags = mount_tab[0].options;
  438. + new_flags = current_flags | (devices ? 0 : MS_NODEV) | MS_NOSUID | (readonly ? MS_RDONLY : 0);
  439. + if (new_flags != current_flags &&
  440. + mount ("none", resolved_dest,
  441. + NULL, MS_MGC_VAL | MS_BIND | MS_REMOUNT | new_flags, NULL) != 0)
  442. + return 3;
  443. +
  444. + /* We need to work around the fact that a bind mount does not apply the flags, so we need to manually
  445. + * apply the flags to all submounts in the recursive case.
  446. + * Note: This does not apply the flags to mounts which are later propagated into this namespace.
  447. + */
  448. + if (recursive)
  449. + {
  450. + for (i = 1; mount_tab[i].mountpoint != NULL; i++)
  451. + {
  452. + current_flags = mount_tab[i].options;
  453. + new_flags = current_flags | (devices ? 0 : MS_NODEV) | MS_NOSUID | (readonly ? MS_RDONLY : 0);
  454. + if (new_flags != current_flags &&
  455. + mount ("none", mount_tab[i].mountpoint,
  456. + NULL, MS_MGC_VAL | MS_BIND | MS_REMOUNT | new_flags, NULL) != 0)
  457. + {
  458. + /* If we can't read the mountpoint we can't remount it, but that should
  459. + be safe to ignore because its not something the user can access. */
  460. + if (errno != EACCES)
  461. + return 5;
  462. + }
  463. + }
  464. + }
  465. +
  466. + return 0;
  467. +}
  468. diff -Nuar flatpak-1.0.0.orig/bubblewrap/bind-mount.h flatpak-1.0.0/bubblewrap/bind-mount.h
  469. --- flatpak-1.0.0.orig/bubblewrap/bind-mount.h 1970-01-01 02:00:00.000000000 +0200
  470. +++ flatpak-1.0.0/bubblewrap/bind-mount.h 2018-02-03 21:26:06.272233339 +0300
  471. @@ -0,0 +1,30 @@
  472. +/* bubblewrap
  473. + * Copyright (C) 2016 Alexander Larsson
  474. + *
  475. + * This program is free software; you can redistribute it and/or
  476. + * modify it under the terms of the GNU Lesser General Public
  477. + * License as published by the Free Software Foundation; either
  478. + * version 2 of the License, or (at your option) any later version.
  479. + *
  480. + * This library is distributed in the hope that it will be useful,
  481. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  482. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  483. + * Lesser General Public License for more details.
  484. + *
  485. + * You should have received a copy of the GNU Lesser General Public
  486. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  487. + *
  488. + */
  489. +
  490. +#pragma once
  491. +
  492. +typedef enum {
  493. + BIND_READONLY = (1 << 0),
  494. + BIND_DEVICES = (1 << 2),
  495. + BIND_RECURSIVE = (1 << 3),
  496. +} bind_option_t;
  497. +
  498. +int bind_mount (int proc_fd,
  499. + const char *src,
  500. + const char *dest,
  501. + bind_option_t options);
  502. diff -Nuar flatpak-1.0.0.orig/bubblewrap/bubblewrap.c flatpak-1.0.0/bubblewrap/bubblewrap.c
  503. --- flatpak-1.0.0.orig/bubblewrap/bubblewrap.c 1970-01-01 02:00:00.000000000 +0200
  504. +++ flatpak-1.0.0/bubblewrap/bubblewrap.c 2018-02-03 21:26:06.272233339 +0300
  505. @@ -0,0 +1,2223 @@
  506. +/* bubblewrap
  507. + * Copyright (C) 2016 Alexander Larsson
  508. + *
  509. + * This program is free software; you can redistribute it and/or
  510. + * modify it under the terms of the GNU Lesser General Public
  511. + * License as published by the Free Software Foundation; either
  512. + * version 2 of the License, or (at your option) any later version.
  513. + *
  514. + * This library is distributed in the hope that it will be useful,
  515. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  516. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  517. + * Lesser General Public License for more details.
  518. + *
  519. + * You should have received a copy of the GNU Lesser General Public
  520. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  521. + *
  522. + */
  523. +
  524. +#include "config.h"
  525. +
  526. +#include <poll.h>
  527. +#include <sched.h>
  528. +#include <pwd.h>
  529. +#include <grp.h>
  530. +#include <sys/mount.h>
  531. +#include <sys/socket.h>
  532. +#include <sys/wait.h>
  533. +#include <sys/eventfd.h>
  534. +#include <sys/fsuid.h>
  535. +#include <sys/signalfd.h>
  536. +#include <sys/capability.h>
  537. +#include <sys/prctl.h>
  538. +#include <linux/sched.h>
  539. +#include <linux/seccomp.h>
  540. +#include <linux/filter.h>
  541. +
  542. +#include "utils.h"
  543. +#include "network.h"
  544. +#include "bind-mount.h"
  545. +
  546. +#ifndef CLONE_NEWCGROUP
  547. +#define CLONE_NEWCGROUP 0x02000000 /* New cgroup namespace */
  548. +#endif
  549. +
  550. +/* Globals to avoid having to use getuid(), since the uid/gid changes during runtime */
  551. +static uid_t real_uid;
  552. +static gid_t real_gid;
  553. +static uid_t overflow_uid;
  554. +static gid_t overflow_gid;
  555. +static bool is_privileged;
  556. +static const char *argv0;
  557. +static const char *host_tty_dev;
  558. +static int proc_fd = -1;
  559. +static char *opt_exec_label = NULL;
  560. +static char *opt_file_label = NULL;
  561. +
  562. +char *opt_chdir_path = NULL;
  563. +bool opt_unshare_user = FALSE;
  564. +bool opt_unshare_user_try = FALSE;
  565. +bool opt_unshare_pid = FALSE;
  566. +bool opt_unshare_ipc = FALSE;
  567. +bool opt_unshare_net = FALSE;
  568. +bool opt_unshare_uts = FALSE;
  569. +bool opt_unshare_cgroup = FALSE;
  570. +bool opt_unshare_cgroup_try = FALSE;
  571. +bool opt_needs_devpts = FALSE;
  572. +bool opt_new_session = FALSE;
  573. +bool opt_die_with_parent = FALSE;
  574. +uid_t opt_sandbox_uid = -1;
  575. +gid_t opt_sandbox_gid = -1;
  576. +int opt_sync_fd = -1;
  577. +int opt_block_fd = -1;
  578. +int opt_info_fd = -1;
  579. +int opt_seccomp_fd = -1;
  580. +char *opt_sandbox_hostname = NULL;
  581. +
  582. +typedef enum {
  583. + SETUP_BIND_MOUNT,
  584. + SETUP_RO_BIND_MOUNT,
  585. + SETUP_DEV_BIND_MOUNT,
  586. + SETUP_MOUNT_PROC,
  587. + SETUP_MOUNT_DEV,
  588. + SETUP_MOUNT_TMPFS,
  589. + SETUP_MOUNT_MQUEUE,
  590. + SETUP_MAKE_DIR,
  591. + SETUP_MAKE_FILE,
  592. + SETUP_MAKE_BIND_FILE,
  593. + SETUP_MAKE_RO_BIND_FILE,
  594. + SETUP_MAKE_SYMLINK,
  595. + SETUP_REMOUNT_RO_NO_RECURSIVE,
  596. + SETUP_SET_HOSTNAME,
  597. +} SetupOpType;
  598. +
  599. +typedef enum {
  600. + NO_CREATE_DEST = (1 << 0),
  601. +} SetupOpFlag;
  602. +
  603. +typedef struct _SetupOp SetupOp;
  604. +
  605. +struct _SetupOp
  606. +{
  607. + SetupOpType type;
  608. + const char *source;
  609. + const char *dest;
  610. + int fd;
  611. + SetupOpFlag flags;
  612. + SetupOp *next;
  613. +};
  614. +
  615. +typedef struct _LockFile LockFile;
  616. +
  617. +struct _LockFile
  618. +{
  619. + const char *path;
  620. + LockFile *next;
  621. +};
  622. +
  623. +static SetupOp *ops = NULL;
  624. +static SetupOp *last_op = NULL;
  625. +static LockFile *lock_files = NULL;
  626. +static LockFile *last_lock_file = NULL;
  627. +
  628. +enum {
  629. + PRIV_SEP_OP_DONE,
  630. + PRIV_SEP_OP_BIND_MOUNT,
  631. + PRIV_SEP_OP_PROC_MOUNT,
  632. + PRIV_SEP_OP_TMPFS_MOUNT,
  633. + PRIV_SEP_OP_DEVPTS_MOUNT,
  634. + PRIV_SEP_OP_MQUEUE_MOUNT,
  635. + PRIV_SEP_OP_REMOUNT_RO_NO_RECURSIVE,
  636. + PRIV_SEP_OP_SET_HOSTNAME,
  637. +};
  638. +
  639. +typedef struct
  640. +{
  641. + uint32_t op;
  642. + uint32_t flags;
  643. + uint32_t arg1_offset;
  644. + uint32_t arg2_offset;
  645. +} PrivSepOp;
  646. +
  647. +static SetupOp *
  648. +setup_op_new (SetupOpType type)
  649. +{
  650. + SetupOp *op = xcalloc (sizeof (SetupOp));
  651. +
  652. + op->type = type;
  653. + op->fd = -1;
  654. + op->flags = 0;
  655. + if (last_op != NULL)
  656. + last_op->next = op;
  657. + else
  658. + ops = op;
  659. +
  660. + last_op = op;
  661. + return op;
  662. +}
  663. +
  664. +static LockFile *
  665. +lock_file_new (const char *path)
  666. +{
  667. + LockFile *lock = xcalloc (sizeof (LockFile));
  668. +
  669. + lock->path = path;
  670. + if (last_lock_file != NULL)
  671. + last_lock_file->next = lock;
  672. + else
  673. + lock_files = lock;
  674. +
  675. + last_lock_file = lock;
  676. + return lock;
  677. +}
  678. +
  679. +
  680. +static void
  681. +usage (int ecode, FILE *out)
  682. +{
  683. + fprintf (out, "usage: %s [OPTIONS...] COMMAND [ARGS...]\n\n", argv0);
  684. +
  685. + fprintf (out,
  686. + " --help Print this help\n"
  687. + " --version Print version\n"
  688. + " --args FD Parse nul-separated args from FD\n"
  689. + " --unshare-all Unshare every namespace we support by default\n"
  690. + " --share-net Retain the network namespace (can only combine with --unshare-all)\n"
  691. + " --unshare-user Create new user namespace (may be automatically implied if not setuid)\n"
  692. + " --unshare-user-try Create new user namespace if possible else continue by skipping it\n"
  693. + " --unshare-ipc Create new ipc namespace\n"
  694. + " --unshare-pid Create new pid namespace\n"
  695. + " --unshare-net Create new network namespace\n"
  696. + " --unshare-uts Create new uts namespace\n"
  697. + " --unshare-cgroup Create new cgroup namespace\n"
  698. + " --unshare-cgroup-try Create new cgroup namespace if possible else continue by skipping it\n"
  699. + " --uid UID Custom uid in the sandbox (requires --unshare-user)\n"
  700. + " --gid GID Custon gid in the sandbox (requires --unshare-user)\n"
  701. + " --hostname NAME Custom hostname in the sandbox (requires --unshare-uts)\n"
  702. + " --chdir DIR Change directory to DIR\n"
  703. + " --setenv VAR VALUE Set an environment variable\n"
  704. + " --unsetenv VAR Unset an environment variable\n"
  705. + " --lock-file DEST Take a lock on DEST while sandbox is running\n"
  706. + " --sync-fd FD Keep this fd open while sandbox is running\n"
  707. + " --bind SRC DEST Bind mount the host path SRC on DEST\n"
  708. + " --dev-bind SRC DEST Bind mount the host path SRC on DEST, allowing device access\n"
  709. + " --ro-bind SRC DEST Bind mount the host path SRC readonly on DEST\n"
  710. + " --remount-ro DEST Remount DEST as readonly, it doesn't recursively remount\n"
  711. + " --exec-label LABEL Exec Label for the sandbox\n"
  712. + " --file-label LABEL File label for temporary sandbox content\n"
  713. + " --proc DEST Mount procfs on DEST\n"
  714. + " --dev DEST Mount new dev on DEST\n"
  715. + " --tmpfs DEST Mount new tmpfs on DEST\n"
  716. + " --mqueue DEST Mount new mqueue on DEST\n"
  717. + " --dir DEST Create dir at DEST\n"
  718. + " --file FD DEST Copy from FD to dest DEST\n"
  719. + " --bind-data FD DEST Copy from FD to file which is bind-mounted on DEST\n"
  720. + " --ro-bind-data FD DEST Copy from FD to file which is readonly bind-mounted on DEST\n"
  721. + " --symlink SRC DEST Create symlink at DEST with target SRC\n"
  722. + " --seccomp FD Load and use seccomp rules from FD\n"
  723. + " --block-fd FD Block on FD until some data to read is available\n"
  724. + " --info-fd FD Write information about the running container to FD\n"
  725. + " --new-session Create a new terminal session\n"
  726. + " --die-with-parent Kills with SIGKILL child process (COMMAND) when bwrap or bwrap's parent dies.\n"
  727. + );
  728. + exit (ecode);
  729. +}
  730. +
  731. +/* If --die-with-parent was specified, use PDEATHSIG to ensure SIGKILL
  732. + * is sent to the current process when our parent dies.
  733. + */
  734. +static void
  735. +handle_die_with_parent (void)
  736. +{
  737. + if (opt_die_with_parent && prctl (PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0) != 0)
  738. + die_with_error ("prctl");
  739. +}
  740. +
  741. +static void
  742. +block_sigchild (void)
  743. +{
  744. + sigset_t mask;
  745. + int status;
  746. +
  747. + sigemptyset (&mask);
  748. + sigaddset (&mask, SIGCHLD);
  749. +
  750. + if (sigprocmask (SIG_BLOCK, &mask, NULL) == -1)
  751. + die_with_error ("sigprocmask");
  752. +
  753. + /* Reap any outstanding zombies that we may have inherited */
  754. + while (waitpid (-1, &status, WNOHANG) > 0)
  755. + ;
  756. +}
  757. +
  758. +static void
  759. +unblock_sigchild (void)
  760. +{
  761. + sigset_t mask;
  762. +
  763. + sigemptyset (&mask);
  764. + sigaddset (&mask, SIGCHLD);
  765. +
  766. + if (sigprocmask (SIG_UNBLOCK, &mask, NULL) == -1)
  767. + die_with_error ("sigprocmask");
  768. +}
  769. +
  770. +/* Closes all fd:s except 0,1,2 and the passed in array of extra fds */
  771. +static int
  772. +close_extra_fds (void *data, int fd)
  773. +{
  774. + int *extra_fds = (int *) data;
  775. + int i;
  776. +
  777. + for (i = 0; extra_fds[i] != -1; i++)
  778. + if (fd == extra_fds[i])
  779. + return 0;
  780. +
  781. + if (fd <= 2)
  782. + return 0;
  783. +
  784. + close (fd);
  785. + return 0;
  786. +}
  787. +
  788. +static int
  789. +propagate_exit_status (int status)
  790. +{
  791. + if (WIFEXITED (status))
  792. + return WEXITSTATUS (status);
  793. +
  794. + /* The process died of a signal, we can't really report that, but we
  795. + * can at least be bash-compatible. The bash manpage says:
  796. + * The return value of a simple command is its
  797. + * exit status, or 128+n if the command is
  798. + * terminated by signal n.
  799. + */
  800. + if (WIFSIGNALED (status))
  801. + return 128 + WTERMSIG (status);
  802. +
  803. + /* Weird? */
  804. + return 255;
  805. +}
  806. +
  807. +/* This stays around for as long as the initial process in the app does
  808. + * and when that exits it exits, propagating the exit status. We do this
  809. + * by having pid 1 in the sandbox detect this exit and tell the monitor
  810. + * the exit status via a eventfd. We also track the exit of the sandbox
  811. + * pid 1 via a signalfd for SIGCHLD, and exit with an error in this case.
  812. + * This is to catch e.g. problems during setup. */
  813. +static void
  814. +monitor_child (int event_fd, pid_t child_pid)
  815. +{
  816. + int res;
  817. + uint64_t val;
  818. + ssize_t s;
  819. + int signal_fd;
  820. + sigset_t mask;
  821. + struct pollfd fds[2];
  822. + int num_fds;
  823. + struct signalfd_siginfo fdsi;
  824. + int dont_close[] = { event_fd, -1 };
  825. + pid_t died_pid;
  826. + int died_status;
  827. +
  828. + /* Close all extra fds in the monitoring process.
  829. + Any passed in fds have been passed on to the child anyway. */
  830. + fdwalk (proc_fd, close_extra_fds, dont_close);
  831. +
  832. + sigemptyset (&mask);
  833. + sigaddset (&mask, SIGCHLD);
  834. +
  835. + signal_fd = signalfd (-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
  836. + if (signal_fd == -1)
  837. + die_with_error ("Can't create signalfd");
  838. +
  839. + num_fds = 1;
  840. + fds[0].fd = signal_fd;
  841. + fds[0].events = POLLIN;
  842. + if (event_fd != -1)
  843. + {
  844. + fds[1].fd = event_fd;
  845. + fds[1].events = POLLIN;
  846. + num_fds++;
  847. + }
  848. +
  849. + while (1)
  850. + {
  851. + fds[0].revents = fds[1].revents = 0;
  852. + res = poll (fds, num_fds, -1);
  853. + if (res == -1 && errno != EINTR)
  854. + die_with_error ("poll");
  855. +
  856. + /* Always read from the eventfd first, if pid 2 died then pid 1 often
  857. + * dies too, and we could race, reporting that first and we'd lose
  858. + * the real exit status. */
  859. + if (event_fd != -1)
  860. + {
  861. + s = read (event_fd, &val, 8);
  862. + if (s == -1 && errno != EINTR && errno != EAGAIN)
  863. + die_with_error ("read eventfd");
  864. + else if (s == 8)
  865. + exit ((int) val - 1);
  866. + }
  867. +
  868. + /* We need to read the signal_fd, or it will keep polling as read,
  869. + * however we ignore the details as we get them from waitpid
  870. + * below anway */
  871. + s = read (signal_fd, &fdsi, sizeof (struct signalfd_siginfo));
  872. + if (s == -1 && errno != EINTR && errno != EAGAIN)
  873. + die_with_error ("read signalfd");
  874. +
  875. + /* We may actually get several sigchld compressed into one
  876. + SIGCHLD, so we have to handle all of them. */
  877. + while ((died_pid = waitpid (-1, &died_status, WNOHANG)) > 0)
  878. + {
  879. + /* We may be getting sigchild from other children too. For instance if
  880. + someone created a child process, and then exec:ed bubblewrap. Ignore them */
  881. + if (died_pid == child_pid)
  882. + exit (propagate_exit_status (died_status));
  883. + }
  884. + }
  885. +}
  886. +
  887. +/* This is pid 1 in the app sandbox. It is needed because we're using
  888. + * pid namespaces, and someone has to reap zombies in it. We also detect
  889. + * when the initial process (pid 2) dies and report its exit status to
  890. + * the monitor so that it can return it to the original spawner.
  891. + *
  892. + * When there are no other processes in the sandbox the wait will return
  893. + * ECHILD, and we then exit pid 1 to clean up the sandbox. */
  894. +static int
  895. +do_init (int event_fd, pid_t initial_pid, struct sock_fprog *seccomp_prog)
  896. +{
  897. + int initial_exit_status = 1;
  898. + LockFile *lock;
  899. +
  900. + for (lock = lock_files; lock != NULL; lock = lock->next)
  901. + {
  902. + int fd = open (lock->path, O_RDONLY | O_CLOEXEC);
  903. + if (fd == -1)
  904. + die_with_error ("Unable to open lock file %s", lock->path);
  905. +
  906. + struct flock l = {
  907. + .l_type = F_RDLCK,
  908. + .l_whence = SEEK_SET,
  909. + .l_start = 0,
  910. + .l_len = 0
  911. + };
  912. +
  913. + if (fcntl (fd, F_SETLK, &l) < 0)
  914. + die_with_error ("Unable to lock file %s", lock->path);
  915. +
  916. + /* Keep fd open to hang on to lock */
  917. + }
  918. +
  919. + /* Optionally bind our lifecycle to that of the caller */
  920. + handle_die_with_parent ();
  921. +
  922. + if (seccomp_prog != NULL &&
  923. + prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, seccomp_prog) != 0)
  924. + die_with_error ("prctl(PR_SET_SECCOMP)");
  925. +
  926. + while (TRUE)
  927. + {
  928. + pid_t child;
  929. + int status;
  930. +
  931. + child = wait (&status);
  932. + if (child == initial_pid && event_fd != -1)
  933. + {
  934. + uint64_t val;
  935. + int res UNUSED;
  936. +
  937. + initial_exit_status = propagate_exit_status (status);
  938. +
  939. + val = initial_exit_status + 1;
  940. + res = write (event_fd, &val, 8);
  941. + /* Ignore res, if e.g. the parent died and closed event_fd
  942. + we don't want to error out here */
  943. + }
  944. +
  945. + if (child == -1 && errno != EINTR)
  946. + {
  947. + if (errno != ECHILD)
  948. + die_with_error ("init wait()");
  949. + break;
  950. + }
  951. + }
  952. +
  953. + return initial_exit_status;
  954. +}
  955. +
  956. +/* low 32bit caps needed */
  957. +#define REQUIRED_CAPS_0 (CAP_TO_MASK (CAP_SYS_ADMIN) | CAP_TO_MASK (CAP_SYS_CHROOT) | CAP_TO_MASK (CAP_NET_ADMIN) | CAP_TO_MASK (CAP_SETUID) | CAP_TO_MASK (CAP_SETGID))
  958. +/* high 32bit caps needed */
  959. +#define REQUIRED_CAPS_1 0
  960. +
  961. +static void
  962. +set_required_caps (void)
  963. +{
  964. + struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 };
  965. + struct __user_cap_data_struct data[2] = { { 0 } };
  966. +
  967. + /* Drop all non-require capabilities */
  968. + data[0].effective = REQUIRED_CAPS_0;
  969. + data[0].permitted = REQUIRED_CAPS_0;
  970. + data[0].inheritable = 0;
  971. + data[1].effective = REQUIRED_CAPS_1;
  972. + data[1].permitted = REQUIRED_CAPS_1;
  973. + data[1].inheritable = 0;
  974. + if (capset (&hdr, data) < 0)
  975. + die_with_error ("capset failed");
  976. +}
  977. +
  978. +static void
  979. +drop_all_caps (void)
  980. +{
  981. + struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 };
  982. + struct __user_cap_data_struct data[2] = { { 0 } };
  983. +
  984. + if (capset (&hdr, data) < 0)
  985. + die_with_error ("capset failed");
  986. +}
  987. +
  988. +static bool
  989. +has_caps (void)
  990. +{
  991. + struct __user_cap_header_struct hdr = { _LINUX_CAPABILITY_VERSION_3, 0 };
  992. + struct __user_cap_data_struct data[2] = { { 0 } };
  993. +
  994. + if (capget (&hdr, data) < 0)
  995. + die_with_error ("capget failed");
  996. +
  997. + return data[0].permitted != 0 || data[1].permitted != 0;
  998. +}
  999. +
  1000. +static void
  1001. +drop_cap_bounding_set (void)
  1002. +{
  1003. + unsigned long cap;
  1004. +
  1005. + /* We ignore both EINVAL and EPERM, as we are actually relying
  1006. + * on PR_SET_NO_NEW_PRIVS to ensure the right capabilities are
  1007. + * available. EPERM in particular can happen with old, buggy
  1008. + * kernels. See:
  1009. + * https://github.com/projectatomic/bubblewrap/pull/175#issuecomment-278051373
  1010. + * https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/security/commoncap.c?id=160da84dbb39443fdade7151bc63a88f8e953077
  1011. + */
  1012. + for (cap = 0; cap <= 63; cap++)
  1013. + {
  1014. + int res = prctl (PR_CAPBSET_DROP, cap, 0, 0, 0);
  1015. + if (res == -1 && !(errno == EINVAL || errno == EPERM))
  1016. + die_with_error ("Dropping capability %ld from bounds", cap);
  1017. + }
  1018. +}
  1019. +
  1020. +/* This acquires the privileges that the bwrap will need it to work.
  1021. + * If bwrap is not setuid, then this does nothing, and it relies on
  1022. + * unprivileged user namespaces to be used. This case is
  1023. + * "is_privileged = FALSE".
  1024. + *
  1025. + * If bwrap is setuid, then we do things in phases.
  1026. + * The first part is run as euid 0, but with with fsuid as the real user.
  1027. + * The second part, inside the child, is run as the real user but with
  1028. + * capabilities.
  1029. + * And finally we drop all capabilities.
  1030. + * The reason for the above dance is to avoid having the setup phase
  1031. + * being able to read files the user can't, while at the same time
  1032. + * working around various kernel issues. See below for details.
  1033. + */
  1034. +static void
  1035. +acquire_privs (void)
  1036. +{
  1037. + uid_t euid, new_fsuid;
  1038. +
  1039. + euid = geteuid ();
  1040. +
  1041. + /* Are we setuid ? */
  1042. + if (real_uid != euid)
  1043. + {
  1044. + if (euid == 0)
  1045. + is_privileged = TRUE;
  1046. + else
  1047. + die ("Unexpected setuid user %d, should be 0", euid);
  1048. +
  1049. + /* We want to keep running as euid=0 until at the clone()
  1050. + * operation because doing so will make the user namespace be
  1051. + * owned by root, which makes it not ptrace:able by the user as
  1052. + * it otherwise would be. After that we will run fully as the
  1053. + * user, which is necessary e.g. to be able to read from a fuse
  1054. + * mount from the user.
  1055. + *
  1056. + * However, we don't want to accidentally mis-use euid=0 for
  1057. + * escalated filesystem access before the clone(), so we set
  1058. + * fsuid to the uid.
  1059. + */
  1060. + if (setfsuid (real_uid) < 0)
  1061. + die_with_error ("Unable to set fsuid");
  1062. +
  1063. + /* setfsuid can't properly report errors, check that it worked (as per manpage) */
  1064. + new_fsuid = setfsuid (-1);
  1065. + if (new_fsuid != real_uid)
  1066. + die ("Unable to set fsuid (was %d)", (int)new_fsuid);
  1067. +
  1068. + /* We never need capabilies after execve(), so lets drop everything from the bounding set */
  1069. + drop_cap_bounding_set ();
  1070. +
  1071. + /* Keep only the required capabilities for setup */
  1072. + set_required_caps ();
  1073. + }
  1074. + else if (real_uid != 0 && has_caps ())
  1075. + {
  1076. + /* We have some capabilities in the non-setuid case, which should not happen.
  1077. + Probably caused by the binary being setcap instead of setuid which we
  1078. + don't support anymore */
  1079. + die ("Unexpected capabilities but not setuid, old file caps config?");
  1080. + }
  1081. +
  1082. + /* Else, we try unprivileged user namespaces */
  1083. +}
  1084. +
  1085. +/* This is called once we're inside the namespace */
  1086. +static void
  1087. +switch_to_user_with_privs (void)
  1088. +{
  1089. + /* If we're in a new user namespace, we got back the bounding set, clear it again */
  1090. + if (opt_unshare_user)
  1091. + drop_cap_bounding_set ();
  1092. +
  1093. + if (!is_privileged)
  1094. + return;
  1095. +
  1096. + /* Tell kernel not clear capabilities when later dropping root uid */
  1097. + if (prctl (PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0)
  1098. + die_with_error ("prctl(PR_SET_KEEPCAPS) failed");
  1099. +
  1100. + if (setuid (opt_sandbox_uid) < 0)
  1101. + die_with_error ("unable to drop root uid");
  1102. +
  1103. + /* Regain effective required capabilities from permitted */
  1104. + set_required_caps ();
  1105. +}
  1106. +
  1107. +static void
  1108. +drop_privs (void)
  1109. +{
  1110. + if (!is_privileged)
  1111. + return;
  1112. +
  1113. + /* Drop root uid */
  1114. + if (setuid (opt_sandbox_uid) < 0)
  1115. + die_with_error ("unable to drop root uid");
  1116. +
  1117. + drop_all_caps ();
  1118. +}
  1119. +
  1120. +static char *
  1121. +get_newroot_path (const char *path)
  1122. +{
  1123. + while (*path == '/')
  1124. + path++;
  1125. + return strconcat ("/newroot/", path);
  1126. +}
  1127. +
  1128. +static char *
  1129. +get_oldroot_path (const char *path)
  1130. +{
  1131. + while (*path == '/')
  1132. + path++;
  1133. + return strconcat ("/oldroot/", path);
  1134. +}
  1135. +
  1136. +static void
  1137. +write_uid_gid_map (uid_t sandbox_uid,
  1138. + uid_t parent_uid,
  1139. + uid_t sandbox_gid,
  1140. + uid_t parent_gid,
  1141. + pid_t pid,
  1142. + bool deny_groups,
  1143. + bool map_root)
  1144. +{
  1145. + cleanup_free char *uid_map = NULL;
  1146. + cleanup_free char *gid_map = NULL;
  1147. + cleanup_free char *dir = NULL;
  1148. + cleanup_fd int dir_fd = -1;
  1149. + uid_t old_fsuid = -1;
  1150. +
  1151. + if (pid == -1)
  1152. + dir = xstrdup ("self");
  1153. + else
  1154. + dir = xasprintf ("%d", pid);
  1155. +
  1156. + dir_fd = openat (proc_fd, dir, O_RDONLY | O_PATH);
  1157. + if (dir_fd < 0)
  1158. + die_with_error ("open /proc/%s failed", dir);
  1159. +
  1160. + if (map_root && parent_uid != 0 && sandbox_uid != 0)
  1161. + uid_map = xasprintf ("0 %d 1\n"
  1162. + "%d %d 1\n", overflow_uid, sandbox_uid, parent_uid);
  1163. + else
  1164. + uid_map = xasprintf ("%d %d 1\n", sandbox_uid, parent_uid);
  1165. +
  1166. + if (map_root && parent_gid != 0 && sandbox_gid != 0)
  1167. + gid_map = xasprintf ("0 %d 1\n"
  1168. + "%d %d 1\n", overflow_gid, sandbox_gid, parent_gid);
  1169. + else
  1170. + gid_map = xasprintf ("%d %d 1\n", sandbox_gid, parent_gid);
  1171. +
  1172. + /* We have to be root to be allowed to write to the uid map
  1173. + * for setuid apps, so temporary set fsuid to 0 */
  1174. + if (is_privileged)
  1175. + old_fsuid = setfsuid (0);
  1176. +
  1177. + if (write_file_at (dir_fd, "uid_map", uid_map) != 0)
  1178. + die_with_error ("setting up uid map");
  1179. +
  1180. + if (deny_groups &&
  1181. + write_file_at (dir_fd, "setgroups", "deny\n") != 0)
  1182. + {
  1183. + /* If /proc/[pid]/setgroups does not exist, assume we are
  1184. + * running a linux kernel < 3.19, i.e. we live with the
  1185. + * vulnerability known as CVE-2014-8989 in older kernels
  1186. + * where setgroups does not exist.
  1187. + */
  1188. + if (errno != ENOENT)
  1189. + die_with_error ("error writing to setgroups");
  1190. + }
  1191. +
  1192. + if (write_file_at (dir_fd, "gid_map", gid_map) != 0)
  1193. + die_with_error ("setting up gid map");
  1194. +
  1195. + if (is_privileged)
  1196. + {
  1197. + setfsuid (old_fsuid);
  1198. + if (setfsuid (-1) != real_uid)
  1199. + die ("Unable to re-set fsuid");
  1200. + }
  1201. +}
  1202. +
  1203. +static void
  1204. +privileged_op (int privileged_op_socket,
  1205. + uint32_t op,
  1206. + uint32_t flags,
  1207. + const char *arg1,
  1208. + const char *arg2)
  1209. +{
  1210. + if (privileged_op_socket != -1)
  1211. + {
  1212. + uint32_t buffer[2048]; /* 8k, but is int32 to guarantee nice alignment */
  1213. + PrivSepOp *op_buffer = (PrivSepOp *) buffer;
  1214. + size_t buffer_size = sizeof (PrivSepOp);
  1215. + uint32_t arg1_offset = 0, arg2_offset = 0;
  1216. +
  1217. + /* We're unprivileged, send this request to the privileged part */
  1218. +
  1219. + if (arg1 != NULL)
  1220. + {
  1221. + arg1_offset = buffer_size;
  1222. + buffer_size += strlen (arg1) + 1;
  1223. + }
  1224. + if (arg2 != NULL)
  1225. + {
  1226. + arg2_offset = buffer_size;
  1227. + buffer_size += strlen (arg2) + 1;
  1228. + }
  1229. +
  1230. + if (buffer_size >= sizeof (buffer))
  1231. + die ("privilege separation operation to large");
  1232. +
  1233. + op_buffer->op = op;
  1234. + op_buffer->flags = flags;
  1235. + op_buffer->arg1_offset = arg1_offset;
  1236. + op_buffer->arg2_offset = arg2_offset;
  1237. + if (arg1 != NULL)
  1238. + strcpy ((char *) buffer + arg1_offset, arg1);
  1239. + if (arg2 != NULL)
  1240. + strcpy ((char *) buffer + arg2_offset, arg2);
  1241. +
  1242. + if (write (privileged_op_socket, buffer, buffer_size) != buffer_size)
  1243. + die ("Can't write to privileged_op_socket");
  1244. +
  1245. + if (read (privileged_op_socket, buffer, 1) != 1)
  1246. + die ("Can't read from privileged_op_socket");
  1247. +
  1248. + return;
  1249. + }
  1250. +
  1251. + /*
  1252. + * This runs a privileged request for the unprivileged setup
  1253. + * code. Note that since the setup code is unprivileged it is not as
  1254. + * trusted, so we need to verify that all requests only affect the
  1255. + * child namespace as set up by the privileged parts of the setup,
  1256. + * and that all the code is very careful about handling input.
  1257. + *
  1258. + * This means:
  1259. + * * Bind mounts are safe, since we always use filesystem namespace. They
  1260. + * must be recursive though, as otherwise you can use a non-recursive bind
  1261. + * mount to access an otherwise over-mounted mountpoint.
  1262. + * * Mounting proc, tmpfs, mqueue, devpts in the child namespace is assumed to
  1263. + * be safe.
  1264. + * * Remounting RO (even non-recursive) is safe because it decreases privileges.
  1265. + * * sethostname() is safe only if we set up a UTS namespace
  1266. + */
  1267. + switch (op)
  1268. + {
  1269. + case PRIV_SEP_OP_DONE:
  1270. + break;
  1271. +
  1272. + case PRIV_SEP_OP_REMOUNT_RO_NO_RECURSIVE:
  1273. + if (bind_mount (proc_fd, NULL, arg2, BIND_READONLY) != 0)
  1274. + die_with_error ("Can't remount readonly on %s", arg2);
  1275. + break;
  1276. +
  1277. + case PRIV_SEP_OP_BIND_MOUNT:
  1278. + /* We always bind directories recursively, otherwise this would let us
  1279. + access files that are otherwise covered on the host */
  1280. + if (bind_mount (proc_fd, arg1, arg2, BIND_RECURSIVE | flags) != 0)
  1281. + die_with_error ("Can't bind mount %s on %s", arg1, arg2);
  1282. + break;
  1283. +
  1284. + case PRIV_SEP_OP_PROC_MOUNT:
  1285. + if (mount ("proc", arg1, "proc", MS_MGC_VAL | MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL) != 0)
  1286. + die_with_error ("Can't mount proc on %s", arg1);
  1287. + break;
  1288. +
  1289. + case PRIV_SEP_OP_TMPFS_MOUNT:
  1290. + {
  1291. + cleanup_free char *opt = label_mount ("mode=0755", opt_file_label);
  1292. + if (mount ("tmpfs", arg1, "tmpfs", MS_MGC_VAL | MS_NOSUID | MS_NODEV, opt) != 0)
  1293. + die_with_error ("Can't mount tmpfs on %s", arg1);
  1294. + break;
  1295. + }
  1296. +
  1297. + case PRIV_SEP_OP_DEVPTS_MOUNT:
  1298. + if (mount ("devpts", arg1, "devpts", MS_MGC_VAL | MS_NOSUID | MS_NOEXEC,
  1299. + "newinstance,ptmxmode=0666,mode=620") != 0)
  1300. + die_with_error ("Can't mount devpts on %s", arg1);
  1301. + break;
  1302. +
  1303. + case PRIV_SEP_OP_MQUEUE_MOUNT:
  1304. + if (mount ("mqueue", arg1, "mqueue", 0, NULL) != 0)
  1305. + die_with_error ("Can't mount mqueue on %s", arg1);
  1306. + break;
  1307. +
  1308. + case PRIV_SEP_OP_SET_HOSTNAME:
  1309. + /* This is checked at the start, but lets verify it here in case
  1310. + something manages to send hacked priv-sep operation requests. */
  1311. + if (!opt_unshare_uts)
  1312. + die ("Refusing to set hostname in original namespace");
  1313. + if (sethostname (arg1, strlen(arg1)) != 0)
  1314. + die_with_error ("Can't set hostname to %s", arg1);
  1315. + break;
  1316. +
  1317. + default:
  1318. + die ("Unexpected privileged op %d", op);
  1319. + }
  1320. +}
  1321. +
  1322. +/* This is run unprivileged in the child namespace but can request
  1323. + * some privileged operations (also in the child namespace) via the
  1324. + * privileged_op_socket.
  1325. + */
  1326. +static void
  1327. +setup_newroot (bool unshare_pid,
  1328. + int privileged_op_socket)
  1329. +{
  1330. + SetupOp *op;
  1331. +
  1332. + for (op = ops; op != NULL; op = op->next)
  1333. + {
  1334. + cleanup_free char *source = NULL;
  1335. + cleanup_free char *dest = NULL;
  1336. + int source_mode = 0;
  1337. + int i;
  1338. +
  1339. + if (op->source &&
  1340. + op->type != SETUP_MAKE_SYMLINK)
  1341. + {
  1342. + source = get_oldroot_path (op->source);
  1343. + source_mode = get_file_mode (source);
  1344. + if (source_mode < 0)
  1345. + die_with_error ("Can't get type of source %s", op->source);
  1346. + }
  1347. +
  1348. + if (op->dest &&
  1349. + (op->flags & NO_CREATE_DEST) == 0)
  1350. + {
  1351. + dest = get_newroot_path (op->dest);
  1352. + if (mkdir_with_parents (dest, 0755, FALSE) != 0)
  1353. + die_with_error ("Can't mkdir parents for %s", op->dest);
  1354. + }
  1355. +
  1356. + switch (op->type)
  1357. + {
  1358. + case SETUP_RO_BIND_MOUNT:
  1359. + case SETUP_DEV_BIND_MOUNT:
  1360. + case SETUP_BIND_MOUNT:
  1361. + if (source_mode == S_IFDIR)
  1362. + {
  1363. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1364. + die_with_error ("Can't mkdir %s", op->dest);
  1365. + }
  1366. + else if (ensure_file (dest, 0666) != 0)
  1367. + die_with_error ("Can't create file at %s", op->dest);
  1368. +
  1369. + privileged_op (privileged_op_socket,
  1370. + PRIV_SEP_OP_BIND_MOUNT,
  1371. + (op->type == SETUP_RO_BIND_MOUNT ? BIND_READONLY : 0) |
  1372. + (op->type == SETUP_DEV_BIND_MOUNT ? BIND_DEVICES : 0),
  1373. + source, dest);
  1374. + break;
  1375. +
  1376. + case SETUP_REMOUNT_RO_NO_RECURSIVE:
  1377. + privileged_op (privileged_op_socket,
  1378. + PRIV_SEP_OP_REMOUNT_RO_NO_RECURSIVE, 0, NULL, dest);
  1379. + break;
  1380. +
  1381. + case SETUP_MOUNT_PROC:
  1382. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1383. + die_with_error ("Can't mkdir %s", op->dest);
  1384. +
  1385. + if (unshare_pid)
  1386. + {
  1387. + /* Our own procfs */
  1388. + privileged_op (privileged_op_socket,
  1389. + PRIV_SEP_OP_PROC_MOUNT, 0,
  1390. + dest, NULL);
  1391. + }
  1392. + else
  1393. + {
  1394. + /* Use system procfs, as we share pid namespace anyway */
  1395. + privileged_op (privileged_op_socket,
  1396. + PRIV_SEP_OP_BIND_MOUNT, 0,
  1397. + "oldroot/proc", dest);
  1398. + }
  1399. +
  1400. + /* There are a bunch of weird old subdirs of /proc that could potentially be
  1401. + problematic (for instance /proc/sysrq-trigger lets you shut down the machine
  1402. + if you have write access). We should not have access to these as a non-privileged
  1403. + user, but lets cover them anyway just to make sure */
  1404. + const char *cover_proc_dirs[] = { "sys", "sysrq-trigger", "irq", "bus" };
  1405. + for (i = 0; i < N_ELEMENTS (cover_proc_dirs); i++)
  1406. + {
  1407. + cleanup_free char *subdir = strconcat3 (dest, "/", cover_proc_dirs[i]);
  1408. + /* Some of these may not exist */
  1409. + if (get_file_mode (subdir) == -1)
  1410. + continue;
  1411. + privileged_op (privileged_op_socket,
  1412. + PRIV_SEP_OP_BIND_MOUNT, BIND_READONLY,
  1413. + subdir, subdir);
  1414. + }
  1415. +
  1416. + break;
  1417. +
  1418. + case SETUP_MOUNT_DEV:
  1419. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1420. + die_with_error ("Can't mkdir %s", op->dest);
  1421. +
  1422. + privileged_op (privileged_op_socket,
  1423. + PRIV_SEP_OP_TMPFS_MOUNT, 0,
  1424. + dest, NULL);
  1425. +
  1426. + static const char *const devnodes[] = { "null", "zero", "full", "random", "urandom", "tty" };
  1427. + for (i = 0; i < N_ELEMENTS (devnodes); i++)
  1428. + {
  1429. + cleanup_free char *node_dest = strconcat3 (dest, "/", devnodes[i]);
  1430. + cleanup_free char *node_src = strconcat ("/oldroot/dev/", devnodes[i]);
  1431. + if (create_file (node_dest, 0666, NULL) != 0)
  1432. + die_with_error ("Can't create file %s/%s", op->dest, devnodes[i]);
  1433. + privileged_op (privileged_op_socket,
  1434. + PRIV_SEP_OP_BIND_MOUNT, BIND_DEVICES,
  1435. + node_src, node_dest);
  1436. + }
  1437. +
  1438. + static const char *const stdionodes[] = { "stdin", "stdout", "stderr" };
  1439. + for (i = 0; i < N_ELEMENTS (stdionodes); i++)
  1440. + {
  1441. + cleanup_free char *target = xasprintf ("/proc/self/fd/%d", i);
  1442. + cleanup_free char *node_dest = strconcat3 (dest, "/", stdionodes[i]);
  1443. + if (symlink (target, node_dest) < 0)
  1444. + die_with_error ("Can't create symlink %s/%s", op->dest, stdionodes[i]);
  1445. + }
  1446. +
  1447. + {
  1448. + cleanup_free char *pts = strconcat (dest, "/pts");
  1449. + cleanup_free char *ptmx = strconcat (dest, "/ptmx");
  1450. + cleanup_free char *shm = strconcat (dest, "/shm");
  1451. +
  1452. + if (mkdir (shm, 0755) == -1)
  1453. + die_with_error ("Can't create %s/shm", op->dest);
  1454. +
  1455. + if (mkdir (pts, 0755) == -1)
  1456. + die_with_error ("Can't create %s/devpts", op->dest);
  1457. + privileged_op (privileged_op_socket,
  1458. + PRIV_SEP_OP_DEVPTS_MOUNT, 0, pts, NULL);
  1459. +
  1460. + if (symlink ("pts/ptmx", ptmx) != 0)
  1461. + die_with_error ("Can't make symlink at %s/ptmx", op->dest);
  1462. + }
  1463. +
  1464. + /* If stdout is a tty, that means the sandbox can write to the
  1465. + outside-sandbox tty. In that case we also create a /dev/console
  1466. + that points to this tty device. This should not cause any more
  1467. + access than we already have, and it makes ttyname() work in the
  1468. + sandbox. */
  1469. + if (host_tty_dev != NULL && *host_tty_dev != 0)
  1470. + {
  1471. + cleanup_free char *src_tty_dev = strconcat ("/oldroot", host_tty_dev);
  1472. + cleanup_free char *dest_console = strconcat (dest, "/console");
  1473. +
  1474. + if (create_file (dest_console, 0666, NULL) != 0)
  1475. + die_with_error ("creating %s/console", op->dest);
  1476. +
  1477. + privileged_op (privileged_op_socket,
  1478. + PRIV_SEP_OP_BIND_MOUNT, BIND_DEVICES,
  1479. + src_tty_dev, dest_console);
  1480. + }
  1481. +
  1482. + break;
  1483. +
  1484. + case SETUP_MOUNT_TMPFS:
  1485. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1486. + die_with_error ("Can't mkdir %s", op->dest);
  1487. +
  1488. + privileged_op (privileged_op_socket,
  1489. + PRIV_SEP_OP_TMPFS_MOUNT, 0,
  1490. + dest, NULL);
  1491. + break;
  1492. +
  1493. + case SETUP_MOUNT_MQUEUE:
  1494. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1495. + die_with_error ("Can't mkdir %s", op->dest);
  1496. +
  1497. + privileged_op (privileged_op_socket,
  1498. + PRIV_SEP_OP_MQUEUE_MOUNT, 0,
  1499. + dest, NULL);
  1500. + break;
  1501. +
  1502. + case SETUP_MAKE_DIR:
  1503. + if (mkdir (dest, 0755) != 0 && errno != EEXIST)
  1504. + die_with_error ("Can't mkdir %s", op->dest);
  1505. +
  1506. + break;
  1507. +
  1508. + case SETUP_MAKE_FILE:
  1509. + {
  1510. + cleanup_fd int dest_fd = -1;
  1511. +
  1512. + dest_fd = creat (dest, 0666);
  1513. + if (dest_fd == -1)
  1514. + die_with_error ("Can't create file %s", op->dest);
  1515. +
  1516. + if (copy_file_data (op->fd, dest_fd) != 0)
  1517. + die_with_error ("Can't write data to file %s", op->dest);
  1518. +
  1519. + close (op->fd);
  1520. + }
  1521. + break;
  1522. +
  1523. + case SETUP_MAKE_BIND_FILE:
  1524. + case SETUP_MAKE_RO_BIND_FILE:
  1525. + {
  1526. + cleanup_fd int dest_fd = -1;
  1527. + char tempfile[] = "/bindfileXXXXXX";
  1528. +
  1529. + dest_fd = mkstemp (tempfile);
  1530. + if (dest_fd == -1)
  1531. + die_with_error ("Can't create tmpfile for %s", op->dest);
  1532. +
  1533. + if (copy_file_data (op->fd, dest_fd) != 0)
  1534. + die_with_error ("Can't write data to file %s", op->dest);
  1535. +
  1536. + close (op->fd);
  1537. +
  1538. + if (ensure_file (dest, 0666) != 0)
  1539. + die_with_error ("Can't create file at %s", op->dest);
  1540. +
  1541. + privileged_op (privileged_op_socket,
  1542. + PRIV_SEP_OP_BIND_MOUNT,
  1543. + (op->type == SETUP_MAKE_RO_BIND_FILE ? BIND_READONLY : 0),
  1544. + tempfile, dest);
  1545. +
  1546. + /* Remove the file so we're sure the app can't get to it in any other way.
  1547. + Its outside the container chroot, so it shouldn't be possible, but lets
  1548. + make it really sure. */
  1549. + unlink (tempfile);
  1550. + }
  1551. + break;
  1552. +
  1553. + case SETUP_MAKE_SYMLINK:
  1554. + if (symlink (op->source, dest) != 0)
  1555. + die_with_error ("Can't make symlink at %s", op->dest);
  1556. + break;
  1557. +
  1558. + case SETUP_SET_HOSTNAME:
  1559. + privileged_op (privileged_op_socket,
  1560. + PRIV_SEP_OP_SET_HOSTNAME, 0,
  1561. + op->dest, NULL);
  1562. + break;
  1563. +
  1564. + default:
  1565. + die ("Unexpected type %d", op->type);
  1566. + }
  1567. + }
  1568. + privileged_op (privileged_op_socket,
  1569. + PRIV_SEP_OP_DONE, 0, NULL, NULL);
  1570. +}
  1571. +
  1572. +/* We need to resolve relative symlinks in the sandbox before we
  1573. + chroot so that absolute symlinks are handled correctly. We also
  1574. + need to do this after we've switched to the real uid so that
  1575. + e.g. paths on fuse mounts work */
  1576. +static void
  1577. +resolve_symlinks_in_ops (void)
  1578. +{
  1579. + SetupOp *op;
  1580. +
  1581. + for (op = ops; op != NULL; op = op->next)
  1582. + {
  1583. + const char *old_source;
  1584. +
  1585. + switch (op->type)
  1586. + {
  1587. + case SETUP_RO_BIND_MOUNT:
  1588. + case SETUP_DEV_BIND_MOUNT:
  1589. + case SETUP_BIND_MOUNT:
  1590. + old_source = op->source;
  1591. + op->source = realpath (old_source, NULL);
  1592. + if (op->source == NULL)
  1593. + die_with_error ("Can't find source path %s", old_source);
  1594. + break;
  1595. + default:
  1596. + break;
  1597. + }
  1598. + }
  1599. +}
  1600. +
  1601. +
  1602. +static const char *
  1603. +resolve_string_offset (void *buffer,
  1604. + size_t buffer_size,
  1605. + uint32_t offset)
  1606. +{
  1607. + if (offset == 0)
  1608. + return NULL;
  1609. +
  1610. + if (offset > buffer_size)
  1611. + die ("Invalid string offset %d (buffer size %zd)", offset, buffer_size);
  1612. +
  1613. + return (const char *) buffer + offset;
  1614. +}
  1615. +
  1616. +static uint32_t
  1617. +read_priv_sec_op (int read_socket,
  1618. + void *buffer,
  1619. + size_t buffer_size,
  1620. + uint32_t *flags,
  1621. + const char **arg1,
  1622. + const char **arg2)
  1623. +{
  1624. + const PrivSepOp *op = (const PrivSepOp *) buffer;
  1625. + ssize_t rec_len;
  1626. +
  1627. + do
  1628. + rec_len = read (read_socket, buffer, buffer_size - 1);
  1629. + while (rec_len == -1 && errno == EINTR);
  1630. +
  1631. + if (rec_len < 0)
  1632. + die_with_error ("Can't read from unprivileged helper");
  1633. +
  1634. + if (rec_len == 0)
  1635. + exit (1); /* Privileged helper died and printed error, so exit silently */
  1636. +
  1637. + if (rec_len < sizeof (PrivSepOp))
  1638. + die ("Invalid size %zd from unprivileged helper", rec_len);
  1639. +
  1640. + /* Guarantee zero termination of any strings */
  1641. + ((char *) buffer)[rec_len] = 0;
  1642. +
  1643. + *flags = op->flags;
  1644. + *arg1 = resolve_string_offset (buffer, rec_len, op->arg1_offset);
  1645. + *arg2 = resolve_string_offset (buffer, rec_len, op->arg2_offset);
  1646. +
  1647. + return op->op;
  1648. +}
  1649. +
  1650. +static void __attribute__ ((noreturn))
  1651. +print_version_and_exit (void)
  1652. +{
  1653. + printf ("%s\n", PACKAGE_STRING);
  1654. + exit (0);
  1655. +}
  1656. +
  1657. +static void
  1658. +parse_args_recurse (int *argcp,
  1659. + char ***argvp,
  1660. + bool in_file,
  1661. + int *total_parsed_argc_p)
  1662. +{
  1663. + SetupOp *op;
  1664. + int argc = *argcp;
  1665. + char **argv = *argvp;
  1666. + /* I can't imagine a case where someone wants more than this.
  1667. + * If you do...you should be able to pass multiple files
  1668. + * via a single tmpfs and linking them there, etc.
  1669. + *
  1670. + * We're adding this hardening due to precedent from
  1671. + * http://googleprojectzero.blogspot.com/2014/08/the-poisoned-nul-byte-2014-edition.html
  1672. + *
  1673. + * I picked 9000 because the Internet told me to and it was hard to
  1674. + * resist.
  1675. + */
  1676. + static const uint32_t MAX_ARGS = 9000;
  1677. +
  1678. + if (*total_parsed_argc_p > MAX_ARGS)
  1679. + die ("Exceeded maximum number of arguments %u", MAX_ARGS);
  1680. +
  1681. + while (argc > 0)
  1682. + {
  1683. + const char *arg = argv[0];
  1684. +
  1685. + if (strcmp (arg, "--help") == 0)
  1686. + {
  1687. + usage (EXIT_SUCCESS, stdout);
  1688. + }
  1689. + else if (strcmp (arg, "--version") == 0)
  1690. + {
  1691. + print_version_and_exit ();
  1692. + }
  1693. + else if (strcmp (arg, "--args") == 0)
  1694. + {
  1695. + int the_fd;
  1696. + char *endptr;
  1697. + char *data, *p;
  1698. + char *data_end;
  1699. + size_t data_len;
  1700. + cleanup_free char **data_argv = NULL;
  1701. + char **data_argv_copy;
  1702. + int data_argc;
  1703. + int i;
  1704. +
  1705. + if (in_file)
  1706. + die ("--args not supported in arguments file");
  1707. +
  1708. + if (argc < 2)
  1709. + die ("--args takes an argument");
  1710. +
  1711. + the_fd = strtol (argv[1], &endptr, 10);
  1712. + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0)
  1713. + die ("Invalid fd: %s", argv[1]);
  1714. +
  1715. + data = load_file_data (the_fd, &data_len);
  1716. + if (data == NULL)
  1717. + die_with_error ("Can't read --args data");
  1718. +
  1719. + data_end = data + data_len;
  1720. + data_argc = 0;
  1721. +
  1722. + p = data;
  1723. + while (p != NULL && p < data_end)
  1724. + {
  1725. + data_argc++;
  1726. + (*total_parsed_argc_p)++;
  1727. + if (*total_parsed_argc_p > MAX_ARGS)
  1728. + die ("Exceeded maximum number of arguments %u", MAX_ARGS);
  1729. + p = memchr (p, 0, data_end - p);
  1730. + if (p != NULL)
  1731. + p++;
  1732. + }
  1733. +
  1734. + data_argv = xcalloc (sizeof (char *) * (data_argc + 1));
  1735. +
  1736. + i = 0;
  1737. + p = data;
  1738. + while (p != NULL && p < data_end)
  1739. + {
  1740. + /* Note: load_file_data always adds a nul terminator, so this is safe
  1741. + * even for the last string. */
  1742. + data_argv[i++] = p;
  1743. + p = memchr (p, 0, data_end - p);
  1744. + if (p != NULL)
  1745. + p++;
  1746. + }
  1747. +
  1748. + data_argv_copy = data_argv; /* Don't change data_argv, we need to free it */
  1749. + parse_args_recurse (&data_argc, &data_argv_copy, TRUE, total_parsed_argc_p);
  1750. +
  1751. + argv += 1;
  1752. + argc -= 1;
  1753. + }
  1754. + else if (strcmp (arg, "--unshare-all") == 0)
  1755. + {
  1756. + /* Keep this in order with the older (legacy) --unshare arguments,
  1757. + * we use the --try variants of user and cgroup, since we want
  1758. + * to support systems/kernels without support for those.
  1759. + */
  1760. + opt_unshare_user_try = opt_unshare_ipc = opt_unshare_pid =
  1761. + opt_unshare_uts = opt_unshare_cgroup_try =
  1762. + opt_unshare_net = TRUE;
  1763. + }
  1764. + /* Begin here the older individual --unshare variants */
  1765. + else if (strcmp (arg, "--unshare-user") == 0)
  1766. + {
  1767. + opt_unshare_user = TRUE;
  1768. + }
  1769. + else if (strcmp (arg, "--unshare-user-try") == 0)
  1770. + {
  1771. + opt_unshare_user_try = TRUE;
  1772. + }
  1773. + else if (strcmp (arg, "--unshare-ipc") == 0)
  1774. + {
  1775. + opt_unshare_ipc = TRUE;
  1776. + }
  1777. + else if (strcmp (arg, "--unshare-pid") == 0)
  1778. + {
  1779. + opt_unshare_pid = TRUE;
  1780. + }
  1781. + else if (strcmp (arg, "--unshare-net") == 0)
  1782. + {
  1783. + opt_unshare_net = TRUE;
  1784. + }
  1785. + else if (strcmp (arg, "--unshare-uts") == 0)
  1786. + {
  1787. + opt_unshare_uts = TRUE;
  1788. + }
  1789. + else if (strcmp (arg, "--unshare-cgroup") == 0)
  1790. + {
  1791. + opt_unshare_cgroup = TRUE;
  1792. + }
  1793. + else if (strcmp (arg, "--unshare-cgroup-try") == 0)
  1794. + {
  1795. + opt_unshare_cgroup_try = TRUE;
  1796. + }
  1797. + /* Begin here the newer --share variants */
  1798. + else if (strcmp (arg, "--share-net") == 0)
  1799. + {
  1800. + opt_unshare_net = FALSE;
  1801. + }
  1802. + /* End --share variants, other arguments begin */
  1803. + else if (strcmp (arg, "--chdir") == 0)
  1804. + {
  1805. + if (argc < 2)
  1806. + die ("--chdir takes one argument");
  1807. +
  1808. + opt_chdir_path = argv[1];
  1809. + argv++;
  1810. + argc--;
  1811. + }
  1812. + else if (strcmp (arg, "--remount-ro") == 0)
  1813. + {
  1814. + if (argc < 2)
  1815. + die ("--remount-ro takes one argument");
  1816. +
  1817. + SetupOp *op = setup_op_new (SETUP_REMOUNT_RO_NO_RECURSIVE);
  1818. + op->dest = argv[1];
  1819. +
  1820. + argv++;
  1821. + argc--;
  1822. + }
  1823. + else if (strcmp (arg, "--bind") == 0)
  1824. + {
  1825. + if (argc < 3)
  1826. + die ("--bind takes two arguments");
  1827. +
  1828. + op = setup_op_new (SETUP_BIND_MOUNT);
  1829. + op->source = argv[1];
  1830. + op->dest = argv[2];
  1831. +
  1832. + argv += 2;
  1833. + argc -= 2;
  1834. + }
  1835. + else if (strcmp (arg, "--ro-bind") == 0)
  1836. + {
  1837. + if (argc < 3)
  1838. + die ("--ro-bind takes two arguments");
  1839. +
  1840. + op = setup_op_new (SETUP_RO_BIND_MOUNT);
  1841. + op->source = argv[1];
  1842. + op->dest = argv[2];
  1843. +
  1844. + argv += 2;
  1845. + argc -= 2;
  1846. + }
  1847. + else if (strcmp (arg, "--dev-bind") == 0)
  1848. + {
  1849. + if (argc < 3)
  1850. + die ("--dev-bind takes two arguments");
  1851. +
  1852. + op = setup_op_new (SETUP_DEV_BIND_MOUNT);
  1853. + op->source = argv[1];
  1854. + op->dest = argv[2];
  1855. +
  1856. + argv += 2;
  1857. + argc -= 2;
  1858. + }
  1859. + else if (strcmp (arg, "--proc") == 0)
  1860. + {
  1861. + if (argc < 2)
  1862. + die ("--proc takes an argument");
  1863. +
  1864. + op = setup_op_new (SETUP_MOUNT_PROC);
  1865. + op->dest = argv[1];
  1866. +
  1867. + argv += 1;
  1868. + argc -= 1;
  1869. + }
  1870. + else if (strcmp (arg, "--exec-label") == 0)
  1871. + {
  1872. + if (argc < 2)
  1873. + die ("--exec-label takes an argument");
  1874. + opt_exec_label = argv[1];
  1875. + die_unless_label_valid (opt_exec_label);
  1876. +
  1877. + argv += 1;
  1878. + argc -= 1;
  1879. + }
  1880. + else if (strcmp (arg, "--file-label") == 0)
  1881. + {
  1882. + if (argc < 2)
  1883. + die ("--file-label takes an argument");
  1884. + opt_file_label = argv[1];
  1885. + die_unless_label_valid (opt_file_label);
  1886. + if (label_create_file (opt_file_label))
  1887. + die_with_error ("--file-label setup failed");
  1888. +
  1889. + argv += 1;
  1890. + argc -= 1;
  1891. + }
  1892. + else if (strcmp (arg, "--dev") == 0)
  1893. + {
  1894. + if (argc < 2)
  1895. + die ("--dev takes an argument");
  1896. +
  1897. + op = setup_op_new (SETUP_MOUNT_DEV);
  1898. + op->dest = argv[1];
  1899. + opt_needs_devpts = TRUE;
  1900. +
  1901. + argv += 1;
  1902. + argc -= 1;
  1903. + }
  1904. + else if (strcmp (arg, "--tmpfs") == 0)
  1905. + {
  1906. + if (argc < 2)
  1907. + die ("--tmpfs takes an argument");
  1908. +
  1909. + op = setup_op_new (SETUP_MOUNT_TMPFS);
  1910. + op->dest = argv[1];
  1911. +
  1912. + argv += 1;
  1913. + argc -= 1;
  1914. + }
  1915. + else if (strcmp (arg, "--mqueue") == 0)
  1916. + {
  1917. + if (argc < 2)
  1918. + die ("--mqueue takes an argument");
  1919. +
  1920. + op = setup_op_new (SETUP_MOUNT_MQUEUE);
  1921. + op->dest = argv[1];
  1922. +
  1923. + argv += 1;
  1924. + argc -= 1;
  1925. + }
  1926. + else if (strcmp (arg, "--dir") == 0)
  1927. + {
  1928. + if (argc < 2)
  1929. + die ("--dir takes an argument");
  1930. +
  1931. + op = setup_op_new (SETUP_MAKE_DIR);
  1932. + op->dest = argv[1];
  1933. +
  1934. + argv += 1;
  1935. + argc -= 1;
  1936. + }
  1937. + else if (strcmp (arg, "--file") == 0)
  1938. + {
  1939. + int file_fd;
  1940. + char *endptr;
  1941. +
  1942. + if (argc < 3)
  1943. + die ("--file takes two arguments");
  1944. +
  1945. + file_fd = strtol (argv[1], &endptr, 10);
  1946. + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0)
  1947. + die ("Invalid fd: %s", argv[1]);
  1948. +
  1949. + op = setup_op_new (SETUP_MAKE_FILE);
  1950. + op->fd = file_fd;
  1951. + op->dest = argv[2];
  1952. +
  1953. + argv += 2;
  1954. + argc -= 2;
  1955. + }
  1956. + else if (strcmp (arg, "--bind-data") == 0)
  1957. + {
  1958. + int file_fd;
  1959. + char *endptr;
  1960. +
  1961. + if (argc < 3)
  1962. + die ("--bind-data takes two arguments");
  1963. +
  1964. + file_fd = strtol (argv[1], &endptr, 10);
  1965. + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0)
  1966. + die ("Invalid fd: %s", argv[1]);
  1967. +
  1968. + op = setup_op_new (SETUP_MAKE_BIND_FILE);
  1969. + op->fd = file_fd;
  1970. + op->dest = argv[2];
  1971. +
  1972. + argv += 2;
  1973. + argc -= 2;
  1974. + }
  1975. + else if (strcmp (arg, "--ro-bind-data") == 0)
  1976. + {
  1977. + int file_fd;
  1978. + char *endptr;
  1979. +
  1980. + if (argc < 3)
  1981. + die ("--ro-bind-data takes two arguments");
  1982. +
  1983. + file_fd = strtol (argv[1], &endptr, 10);
  1984. + if (argv[1][0] == 0 || endptr[0] != 0 || file_fd < 0)
  1985. + die ("Invalid fd: %s", argv[1]);
  1986. +
  1987. + op = setup_op_new (SETUP_MAKE_RO_BIND_FILE);
  1988. + op->fd = file_fd;
  1989. + op->dest = argv[2];
  1990. +
  1991. + argv += 2;
  1992. + argc -= 2;
  1993. + }
  1994. + else if (strcmp (arg, "--symlink") == 0)
  1995. + {
  1996. + if (argc < 3)
  1997. + die ("--symlink takes two arguments");
  1998. +
  1999. + op = setup_op_new (SETUP_MAKE_SYMLINK);
  2000. + op->source = argv[1];
  2001. + op->dest = argv[2];
  2002. +
  2003. + argv += 2;
  2004. + argc -= 2;
  2005. + }
  2006. + else if (strcmp (arg, "--lock-file") == 0)
  2007. + {
  2008. + if (argc < 2)
  2009. + die ("--lock-file takes an argument");
  2010. +
  2011. + (void) lock_file_new (argv[1]);
  2012. +
  2013. + argv += 1;
  2014. + argc -= 1;
  2015. + }
  2016. + else if (strcmp (arg, "--sync-fd") == 0)
  2017. + {
  2018. + int the_fd;
  2019. + char *endptr;
  2020. +
  2021. + if (argc < 2)
  2022. + die ("--sync-fd takes an argument");
  2023. +
  2024. + the_fd = strtol (argv[1], &endptr, 10);
  2025. + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0)
  2026. + die ("Invalid fd: %s", argv[1]);
  2027. +
  2028. + opt_sync_fd = the_fd;
  2029. +
  2030. + argv += 1;
  2031. + argc -= 1;
  2032. + }
  2033. + else if (strcmp (arg, "--block-fd") == 0)
  2034. + {
  2035. + int the_fd;
  2036. + char *endptr;
  2037. +
  2038. + if (argc < 2)
  2039. + die ("--block-fd takes an argument");
  2040. +
  2041. + the_fd = strtol (argv[1], &endptr, 10);
  2042. + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0)
  2043. + die ("Invalid fd: %s", argv[1]);
  2044. +
  2045. + opt_block_fd = the_fd;
  2046. +
  2047. + argv += 1;
  2048. + argc -= 1;
  2049. + }
  2050. + else if (strcmp (arg, "--info-fd") == 0)
  2051. + {
  2052. + int the_fd;
  2053. + char *endptr;
  2054. +
  2055. + if (argc < 2)
  2056. + die ("--info-fd takes an argument");
  2057. +
  2058. + the_fd = strtol (argv[1], &endptr, 10);
  2059. + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0)
  2060. + die ("Invalid fd: %s", argv[1]);
  2061. +
  2062. + opt_info_fd = the_fd;
  2063. +
  2064. + argv += 1;
  2065. + argc -= 1;
  2066. + }
  2067. + else if (strcmp (arg, "--seccomp") == 0)
  2068. + {
  2069. + int the_fd;
  2070. + char *endptr;
  2071. +
  2072. + if (argc < 2)
  2073. + die ("--seccomp takes an argument");
  2074. +
  2075. + the_fd = strtol (argv[1], &endptr, 10);
  2076. + if (argv[1][0] == 0 || endptr[0] != 0 || the_fd < 0)
  2077. + die ("Invalid fd: %s", argv[1]);
  2078. +
  2079. + opt_seccomp_fd = the_fd;
  2080. +
  2081. + argv += 1;
  2082. + argc -= 1;
  2083. + }
  2084. + else if (strcmp (arg, "--setenv") == 0)
  2085. + {
  2086. + if (argc < 3)
  2087. + die ("--setenv takes two arguments");
  2088. +
  2089. + xsetenv (argv[1], argv[2], 1);
  2090. +
  2091. + argv += 2;
  2092. + argc -= 2;
  2093. + }
  2094. + else if (strcmp (arg, "--unsetenv") == 0)
  2095. + {
  2096. + if (argc < 2)
  2097. + die ("--unsetenv takes an argument");
  2098. +
  2099. + xunsetenv (argv[1]);
  2100. +
  2101. + argv += 1;
  2102. + argc -= 1;
  2103. + }
  2104. + else if (strcmp (arg, "--uid") == 0)
  2105. + {
  2106. + int the_uid;
  2107. + char *endptr;
  2108. +
  2109. + if (argc < 2)
  2110. + die ("--uid takes an argument");
  2111. +
  2112. + the_uid = strtol (argv[1], &endptr, 10);
  2113. + if (argv[1][0] == 0 || endptr[0] != 0 || the_uid < 0)
  2114. + die ("Invalid uid: %s", argv[1]);
  2115. +
  2116. + opt_sandbox_uid = the_uid;
  2117. +
  2118. + argv += 1;
  2119. + argc -= 1;
  2120. + }
  2121. + else if (strcmp (arg, "--gid") == 0)
  2122. + {
  2123. + int the_gid;
  2124. + char *endptr;
  2125. +
  2126. + if (argc < 2)
  2127. + die ("--gid takes an argument");
  2128. +
  2129. + the_gid = strtol (argv[1], &endptr, 10);
  2130. + if (argv[1][0] == 0 || endptr[0] != 0 || the_gid < 0)
  2131. + die ("Invalid gid: %s", argv[1]);
  2132. +
  2133. + opt_sandbox_gid = the_gid;
  2134. +
  2135. + argv += 1;
  2136. + argc -= 1;
  2137. + }
  2138. + else if (strcmp (arg, "--hostname") == 0)
  2139. + {
  2140. + if (argc < 2)
  2141. + die ("--hostname takes an argument");
  2142. +
  2143. + op = setup_op_new (SETUP_SET_HOSTNAME);
  2144. + op->dest = argv[1];
  2145. + op->flags = NO_CREATE_DEST;
  2146. +
  2147. + opt_sandbox_hostname = argv[1];
  2148. +
  2149. + argv += 1;
  2150. + argc -= 1;
  2151. + }
  2152. + else if (strcmp (arg, "--new-session") == 0)
  2153. + {
  2154. + opt_new_session = TRUE;
  2155. + }
  2156. + else if (strcmp (arg, "--die-with-parent") == 0)
  2157. + {
  2158. + opt_die_with_parent = TRUE;
  2159. + }
  2160. + else if (*arg == '-')
  2161. + {
  2162. + die ("Unknown option %s", arg);
  2163. + }
  2164. + else
  2165. + {
  2166. + break;
  2167. + }
  2168. +
  2169. + argv++;
  2170. + argc--;
  2171. + }
  2172. +
  2173. + *argcp = argc;
  2174. + *argvp = argv;
  2175. +}
  2176. +
  2177. +static void
  2178. +parse_args (int *argcp,
  2179. + char ***argvp)
  2180. +{
  2181. + int total_parsed_argc = *argcp;
  2182. +
  2183. + parse_args_recurse (argcp, argvp, FALSE, &total_parsed_argc);
  2184. +}
  2185. +
  2186. +static void
  2187. +read_overflowids (void)
  2188. +{
  2189. + cleanup_free char *uid_data = NULL;
  2190. + cleanup_free char *gid_data = NULL;
  2191. +
  2192. + uid_data = load_file_at (AT_FDCWD, "/proc/sys/kernel/overflowuid");
  2193. + if (uid_data == NULL)
  2194. + die_with_error ("Can't read /proc/sys/kernel/overflowuid");
  2195. +
  2196. + overflow_uid = strtol (uid_data, NULL, 10);
  2197. + if (overflow_uid == 0)
  2198. + die ("Can't parse /proc/sys/kernel/overflowuid");
  2199. +
  2200. + gid_data = load_file_at (AT_FDCWD, "/proc/sys/kernel/overflowgid");
  2201. + if (gid_data == NULL)
  2202. + die_with_error ("Can't read /proc/sys/kernel/overflowgid");
  2203. +
  2204. + overflow_gid = strtol (gid_data, NULL, 10);
  2205. + if (overflow_gid == 0)
  2206. + die ("Can't parse /proc/sys/kernel/overflowgid");
  2207. +}
  2208. +
  2209. +int
  2210. +main (int argc,
  2211. + char **argv)
  2212. +{
  2213. + mode_t old_umask;
  2214. + cleanup_free char *base_path = NULL;
  2215. + int clone_flags;
  2216. + char *old_cwd = NULL;
  2217. + pid_t pid;
  2218. + int event_fd = -1;
  2219. + int child_wait_fd = -1;
  2220. + const char *new_cwd;
  2221. + uid_t ns_uid;
  2222. + gid_t ns_gid;
  2223. + struct stat sbuf;
  2224. + uint64_t val;
  2225. + int res UNUSED;
  2226. + cleanup_free char *seccomp_data = NULL;
  2227. + size_t seccomp_len;
  2228. + struct sock_fprog seccomp_prog;
  2229. +
  2230. + /* Handle --version early on before we try to acquire/drop
  2231. + * any capabilities so it works in a build environment;
  2232. + * right now flatpak's build runs bubblewrap --version.
  2233. + * https://github.com/projectatomic/bubblewrap/issues/185
  2234. + */
  2235. + if (argc == 2 && (strcmp (argv[1], "--version") == 0))
  2236. + print_version_and_exit ();
  2237. +
  2238. + real_uid = getuid ();
  2239. + real_gid = getgid ();
  2240. +
  2241. + /* Get the (optional) privileges we need */
  2242. + acquire_privs ();
  2243. +
  2244. + /* Never gain any more privs during exec */
  2245. + if (prctl (PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0)
  2246. + die_with_error ("prctl(PR_SET_NO_NEW_CAPS) failed");
  2247. +
  2248. + /* The initial code is run with high permissions
  2249. + (i.e. CAP_SYS_ADMIN), so take lots of care. */
  2250. +
  2251. + read_overflowids ();
  2252. +
  2253. + argv0 = argv[0];
  2254. +
  2255. + if (isatty (1))
  2256. + host_tty_dev = ttyname (1);
  2257. +
  2258. + argv++;
  2259. + argc--;
  2260. +
  2261. + if (argc == 0)
  2262. + usage (EXIT_FAILURE, stderr);
  2263. +
  2264. + parse_args (&argc, &argv);
  2265. +
  2266. + /* We have to do this if we weren't installed setuid (and we're not
  2267. + * root), so let's just DWIM */
  2268. + if (!is_privileged && getuid () != 0)
  2269. + opt_unshare_user = TRUE;
  2270. +
  2271. +#ifdef ENABLE_REQUIRE_USERNS
  2272. + /* In this build option, we require userns. */
  2273. + if (is_privileged && getuid () != 0)
  2274. + opt_unshare_user = TRUE;
  2275. +#endif
  2276. +
  2277. + if (opt_unshare_user_try &&
  2278. + stat ("/proc/self/ns/user", &sbuf) == 0)
  2279. + {
  2280. + bool disabled = FALSE;
  2281. +
  2282. + /* RHEL7 has a kernel module parameter that lets you enable user namespaces */
  2283. + if (stat ("/sys/module/user_namespace/parameters/enable", &sbuf) == 0)
  2284. + {
  2285. + cleanup_free char *enable = NULL;
  2286. + enable = load_file_at (AT_FDCWD, "/sys/module/user_namespace/parameters/enable");
  2287. + if (enable != NULL && enable[0] == 'N')
  2288. + disabled = TRUE;
  2289. + }
  2290. +
  2291. + /* Debian lets you disable *unprivileged* user namespaces. However this is not
  2292. + a problem if we're privileged, and if we're not opt_unshare_user is TRUE
  2293. + already, and there is not much we can do, its just a non-working setup. */
  2294. +
  2295. + if (!disabled)
  2296. + opt_unshare_user = TRUE;
  2297. + }
  2298. +
  2299. + if (argc == 0)
  2300. + usage (EXIT_FAILURE, stderr);
  2301. +
  2302. + __debug__ (("Creating root mount point\n"));
  2303. +
  2304. + if (opt_sandbox_uid == -1)
  2305. + opt_sandbox_uid = real_uid;
  2306. + if (opt_sandbox_gid == -1)
  2307. + opt_sandbox_gid = real_gid;
  2308. +
  2309. + if (!opt_unshare_user && opt_sandbox_uid != real_uid)
  2310. + die ("Specifying --uid requires --unshare-user");
  2311. +
  2312. + if (!opt_unshare_user && opt_sandbox_gid != real_gid)
  2313. + die ("Specifying --gid requires --unshare-user");
  2314. +
  2315. + if (!opt_unshare_uts && opt_sandbox_hostname != NULL)
  2316. + die ("Specifying --hostname requires --unshare-uts");
  2317. +
  2318. + /* We need to read stuff from proc during the pivot_root dance, etc.
  2319. + Lets keep a fd to it open */
  2320. + proc_fd = open ("/proc", O_RDONLY | O_PATH);
  2321. + if (proc_fd == -1)
  2322. + die_with_error ("Can't open /proc");
  2323. +
  2324. + /* We need *some* mountpoint where we can mount the root tmpfs.
  2325. + We first try in /run, and if that fails, try in /tmp. */
  2326. + base_path = xasprintf ("/run/user/%d/.bubblewrap", real_uid);
  2327. + if (mkdir (base_path, 0755) && errno != EEXIST)
  2328. + {
  2329. + free (base_path);
  2330. + base_path = xasprintf ("/tmp/.bubblewrap-%d", real_uid);
  2331. + if (mkdir (base_path, 0755) && errno != EEXIST)
  2332. + die_with_error ("Creating root mountpoint failed");
  2333. + }
  2334. +
  2335. + __debug__ (("creating new namespace\n"));
  2336. +
  2337. + if (opt_unshare_pid)
  2338. + {
  2339. + event_fd = eventfd (0, EFD_CLOEXEC | EFD_NONBLOCK);
  2340. + if (event_fd == -1)
  2341. + die_with_error ("eventfd()");
  2342. + }
  2343. +
  2344. + /* We block sigchild here so that we can use signalfd in the monitor. */
  2345. + block_sigchild ();
  2346. +
  2347. + clone_flags = SIGCHLD | CLONE_NEWNS;
  2348. + if (opt_unshare_user)
  2349. + clone_flags |= CLONE_NEWUSER;
  2350. + if (opt_unshare_pid)
  2351. + clone_flags |= CLONE_NEWPID;
  2352. + if (opt_unshare_net)
  2353. + clone_flags |= CLONE_NEWNET;
  2354. + if (opt_unshare_ipc)
  2355. + clone_flags |= CLONE_NEWIPC;
  2356. + if (opt_unshare_uts)
  2357. + clone_flags |= CLONE_NEWUTS;
  2358. + if (opt_unshare_cgroup)
  2359. + {
  2360. + if (stat ("/proc/self/ns/cgroup", &sbuf))
  2361. + {
  2362. + if (errno == ENOENT)
  2363. + die ("Cannot create new cgroup namespace because the kernel does not support it");
  2364. + else
  2365. + die_with_error ("stat on /proc/self/ns/cgroup failed");
  2366. + }
  2367. + clone_flags |= CLONE_NEWCGROUP;
  2368. + }
  2369. + if (opt_unshare_cgroup_try)
  2370. + if (!stat ("/proc/self/ns/cgroup", &sbuf))
  2371. + clone_flags |= CLONE_NEWCGROUP;
  2372. +
  2373. + child_wait_fd = eventfd (0, EFD_CLOEXEC);
  2374. + if (child_wait_fd == -1)
  2375. + die_with_error ("eventfd()");
  2376. +
  2377. + pid = raw_clone (clone_flags, NULL);
  2378. + if (pid == -1)
  2379. + {
  2380. + if (opt_unshare_user)
  2381. + {
  2382. + if (errno == EINVAL)
  2383. + die ("Creating new namespace failed, likely because the kernel does not support user namespaces. bwrap must be installed setuid on such systems.");
  2384. + else if (errno == EPERM && !is_privileged)
  2385. + die ("No permissions to creating new namespace, likely because the kernel does not allow non-privileged user namespaces. On e.g. debian this can be enabled with 'sysctl kernel.unprivileged_userns_clone=1'.");
  2386. + }
  2387. +
  2388. + die_with_error ("Creating new namespace failed");
  2389. + }
  2390. +
  2391. + ns_uid = opt_sandbox_uid;
  2392. + ns_gid = opt_sandbox_gid;
  2393. +
  2394. + if (pid != 0)
  2395. + {
  2396. + /* Parent, outside sandbox, privileged (initially) */
  2397. +
  2398. + if (is_privileged && opt_unshare_user)
  2399. + {
  2400. + /* We're running as euid 0, but the uid we want to map is
  2401. + * not 0. This means we're not allowed to write this from
  2402. + * the child user namespace, so we do it from the parent.
  2403. + *
  2404. + * Also, we map uid/gid 0 in the namespace (to overflowuid)
  2405. + * if opt_needs_devpts is true, because otherwise the mount
  2406. + * of devpts fails due to root not being mapped.
  2407. + */
  2408. + write_uid_gid_map (ns_uid, real_uid,
  2409. + ns_gid, real_gid,
  2410. + pid, TRUE, opt_needs_devpts);
  2411. + }
  2412. +
  2413. + /* Initial launched process, wait for exec:ed command to exit */
  2414. +
  2415. + /* We don't need any privileges in the launcher, drop them immediately. */
  2416. + drop_privs ();
  2417. +
  2418. + /* Optionally bind our lifecycle to that of the parent */
  2419. + handle_die_with_parent ();
  2420. +
  2421. + /* Let child run now that the uid maps are set up */
  2422. + val = 1;
  2423. + res = write (child_wait_fd, &val, 8);
  2424. + /* Ignore res, if e.g. the child died and closed child_wait_fd we don't want to error out here */
  2425. + close (child_wait_fd);
  2426. +
  2427. + if (opt_info_fd != -1)
  2428. + {
  2429. + cleanup_free char *output = xasprintf ("{\n \"child-pid\": %i\n}\n", pid);
  2430. + size_t len = strlen (output);
  2431. + if (write (opt_info_fd, output, len) != len)
  2432. + die_with_error ("Write to info_fd");
  2433. + close (opt_info_fd);
  2434. + }
  2435. +
  2436. + monitor_child (event_fd, pid);
  2437. + exit (0); /* Should not be reached, but better safe... */
  2438. + }
  2439. +
  2440. + /* Child, in sandbox, privileged in the parent or in the user namespace (if --unshare-user).
  2441. + *
  2442. + * Note that for user namespaces we run as euid 0 during clone(), so
  2443. + * the child user namespace is owned by euid 0., This means that the
  2444. + * regular user namespace parent (with uid != 0) doesn't have any
  2445. + * capabilities in it, which is nice as we can't exploit those. In
  2446. + * particular the parent user namespace doesn't have CAP_PTRACE
  2447. + * which would otherwise allow the parent to hijack of the child
  2448. + * after this point.
  2449. + *
  2450. + * Unfortunately this also means you can't ptrace the final
  2451. + * sandboxed process from outside the sandbox either.
  2452. + */
  2453. +
  2454. + if (opt_info_fd != -1)
  2455. + close (opt_info_fd);
  2456. +
  2457. + /* Wait for the parent to init uid/gid maps and drop caps */
  2458. + res = read (child_wait_fd, &val, 8);
  2459. + close (child_wait_fd);
  2460. +
  2461. + /* At this point we can completely drop root uid, but retain the
  2462. + * required permitted caps. This allow us to do full setup as
  2463. + * the user uid, which makes e.g. fuse access work.
  2464. + */
  2465. + switch_to_user_with_privs ();
  2466. +
  2467. + if (opt_unshare_net)
  2468. + loopback_setup (); /* Will exit if unsuccessful */
  2469. +
  2470. + ns_uid = opt_sandbox_uid;
  2471. + ns_gid = opt_sandbox_gid;
  2472. + if (!is_privileged && opt_unshare_user)
  2473. + {
  2474. + /* In the unprivileged case we have to write the uid/gid maps in
  2475. + * the child, because we have no caps in the parent */
  2476. +
  2477. + if (opt_needs_devpts)
  2478. + {
  2479. + /* This is a bit hacky, but we need to first map the real uid/gid to
  2480. + 0, otherwise we can't mount the devpts filesystem because root is
  2481. + not mapped. Later we will create another child user namespace and
  2482. + map back to the real uid */
  2483. + ns_uid = 0;
  2484. + ns_gid = 0;
  2485. + }
  2486. +
  2487. + write_uid_gid_map (ns_uid, real_uid,
  2488. + ns_gid, real_gid,
  2489. + -1, TRUE, FALSE);
  2490. + }
  2491. +
  2492. + old_umask = umask (0);
  2493. +
  2494. + /* Need to do this before the chroot, but after we're the real uid */
  2495. + resolve_symlinks_in_ops ();
  2496. +
  2497. + /* Mark everything as slave, so that we still
  2498. + * receive mounts from the real root, but don't
  2499. + * propagate mounts to the real root. */
  2500. + if (mount (NULL, "/", NULL, MS_SLAVE | MS_REC, NULL) < 0)
  2501. + die_with_error ("Failed to make / slave");
  2502. +
  2503. + /* Create a tmpfs which we will use as / in the namespace */
  2504. + if (mount ("", base_path, "tmpfs", MS_NODEV | MS_NOSUID, NULL) != 0)
  2505. + die_with_error ("Failed to mount tmpfs");
  2506. +
  2507. + old_cwd = get_current_dir_name ();
  2508. +
  2509. + /* Chdir to the new root tmpfs mount. This will be the CWD during
  2510. + the entire setup. Access old or new root via "oldroot" and "newroot". */
  2511. + if (chdir (base_path) != 0)
  2512. + die_with_error ("chdir base_path");
  2513. +
  2514. + /* We create a subdir "$base_path/newroot" for the new root, that
  2515. + * way we can pivot_root to base_path, and put the old root at
  2516. + * "$base_path/oldroot". This avoids problems accessing the oldroot
  2517. + * dir if the user requested to bind mount something over / */
  2518. +
  2519. + if (mkdir ("newroot", 0755))
  2520. + die_with_error ("Creating newroot failed");
  2521. +
  2522. + if (mkdir ("oldroot", 0755))
  2523. + die_with_error ("Creating oldroot failed");
  2524. +
  2525. + if (pivot_root (base_path, "oldroot"))
  2526. + die_with_error ("pivot_root");
  2527. +
  2528. + if (chdir ("/") != 0)
  2529. + die_with_error ("chdir / (base path)");
  2530. +
  2531. + if (is_privileged)
  2532. + {
  2533. + pid_t child;
  2534. + int privsep_sockets[2];
  2535. +
  2536. + if (socketpair (AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, privsep_sockets) != 0)
  2537. + die_with_error ("Can't create privsep socket");
  2538. +
  2539. + child = fork ();
  2540. + if (child == -1)
  2541. + die_with_error ("Can't fork unprivileged helper");
  2542. +
  2543. + if (child == 0)
  2544. + {
  2545. + /* Unprivileged setup process */
  2546. + drop_privs ();
  2547. + close (privsep_sockets[0]);
  2548. + setup_newroot (opt_unshare_pid, privsep_sockets[1]);
  2549. + exit (0);
  2550. + }
  2551. + else
  2552. + {
  2553. + int status;
  2554. + uint32_t buffer[2048]; /* 8k, but is int32 to guarantee nice alignment */
  2555. + uint32_t op, flags;
  2556. + const char *arg1, *arg2;
  2557. + cleanup_fd int unpriv_socket = -1;
  2558. +
  2559. + unpriv_socket = privsep_sockets[0];
  2560. + close (privsep_sockets[1]);
  2561. +
  2562. + do
  2563. + {
  2564. + op = read_priv_sec_op (unpriv_socket, buffer, sizeof (buffer),
  2565. + &flags, &arg1, &arg2);
  2566. + privileged_op (-1, op, flags, arg1, arg2);
  2567. + if (write (unpriv_socket, buffer, 1) != 1)
  2568. + die ("Can't write to op_socket");
  2569. + }
  2570. + while (op != PRIV_SEP_OP_DONE);
  2571. +
  2572. + waitpid (child, &status, 0);
  2573. + /* Continue post setup */
  2574. + }
  2575. + }
  2576. + else
  2577. + {
  2578. + setup_newroot (opt_unshare_pid, -1);
  2579. + }
  2580. +
  2581. + /* The old root better be rprivate or we will send unmount events to the parent namespace */
  2582. + if (mount ("oldroot", "oldroot", NULL, MS_REC | MS_PRIVATE, NULL) != 0)
  2583. + die_with_error ("Failed to make old root rprivate");
  2584. +
  2585. + if (umount2 ("oldroot", MNT_DETACH))
  2586. + die_with_error ("unmount old root");
  2587. +
  2588. + if (opt_unshare_user &&
  2589. + (ns_uid != opt_sandbox_uid || ns_gid != opt_sandbox_gid))
  2590. + {
  2591. + /* Now that devpts is mounted and we've no need for mount
  2592. + permissions we can create a new userspace and map our uid
  2593. + 1:1 */
  2594. +
  2595. + if (unshare (CLONE_NEWUSER))
  2596. + die_with_error ("unshare user ns");
  2597. +
  2598. + write_uid_gid_map (opt_sandbox_uid, ns_uid,
  2599. + opt_sandbox_gid, ns_gid,
  2600. + -1, FALSE, FALSE);
  2601. + }
  2602. +
  2603. + /* Now make /newroot the real root */
  2604. + if (chdir ("/newroot") != 0)
  2605. + die_with_error ("chdir newroot");
  2606. + if (chroot ("/newroot") != 0)
  2607. + die_with_error ("chroot /newroot");
  2608. + if (chdir ("/") != 0)
  2609. + die_with_error ("chdir /");
  2610. +
  2611. + /* All privileged ops are done now, so drop it */
  2612. + drop_privs ();
  2613. +
  2614. + if (opt_block_fd != -1)
  2615. + {
  2616. + char b[1];
  2617. + read (opt_block_fd, b, 1);
  2618. + close (opt_block_fd);
  2619. + }
  2620. +
  2621. + if (opt_seccomp_fd != -1)
  2622. + {
  2623. + seccomp_data = load_file_data (opt_seccomp_fd, &seccomp_len);
  2624. + if (seccomp_data == NULL)
  2625. + die_with_error ("Can't read seccomp data");
  2626. +
  2627. + if (seccomp_len % 8 != 0)
  2628. + die ("Invalid seccomp data, must be multiple of 8");
  2629. +
  2630. + seccomp_prog.len = seccomp_len / 8;
  2631. + seccomp_prog.filter = (struct sock_filter *) seccomp_data;
  2632. +
  2633. + close (opt_seccomp_fd);
  2634. + }
  2635. +
  2636. + umask (old_umask);
  2637. +
  2638. + new_cwd = "/";
  2639. + if (opt_chdir_path)
  2640. + {
  2641. + if (chdir (opt_chdir_path))
  2642. + die_with_error ("Can't chdir to %s", opt_chdir_path);
  2643. + new_cwd = opt_chdir_path;
  2644. + }
  2645. + else if (chdir (old_cwd) == 0)
  2646. + {
  2647. + /* If the old cwd is mapped in the sandbox, go there */
  2648. + new_cwd = old_cwd;
  2649. + }
  2650. + else
  2651. + {
  2652. + /* If the old cwd is not mapped, go to home */
  2653. + const char *home = getenv ("HOME");
  2654. + if (home != NULL &&
  2655. + chdir (home) == 0)
  2656. + new_cwd = home;
  2657. + }
  2658. + xsetenv ("PWD", new_cwd, 1);
  2659. + free (old_cwd);
  2660. +
  2661. + if (opt_new_session &&
  2662. + setsid () == (pid_t) -1)
  2663. + die_with_error ("setsid");
  2664. +
  2665. + if (label_exec (opt_exec_label) == -1)
  2666. + die_with_error ("label_exec %s", argv[0]);
  2667. +
  2668. + __debug__ (("forking for child\n"));
  2669. +
  2670. + if (opt_unshare_pid || lock_files != NULL || opt_sync_fd != -1)
  2671. + {
  2672. + /* We have to have a pid 1 in the pid namespace, because
  2673. + * otherwise we'll get a bunch of zombies as nothing reaps
  2674. + * them. Alternatively if we're using sync_fd or lock_files we
  2675. + * need some process to own these.
  2676. + */
  2677. +
  2678. + pid = fork ();
  2679. + if (pid == -1)
  2680. + die_with_error ("Can't fork for pid 1");
  2681. +
  2682. + if (pid != 0)
  2683. + {
  2684. + /* Close fds in pid 1, except stdio and optionally event_fd
  2685. + (for syncing pid 2 lifetime with monitor_child) and
  2686. + opt_sync_fd (for syncing sandbox lifetime with outside
  2687. + process).
  2688. + Any other fds will been passed on to the child though. */
  2689. + {
  2690. + int dont_close[3];
  2691. + int j = 0;
  2692. + if (event_fd != -1)
  2693. + dont_close[j++] = event_fd;
  2694. + if (opt_sync_fd != -1)
  2695. + dont_close[j++] = opt_sync_fd;
  2696. + dont_close[j++] = -1;
  2697. + fdwalk (proc_fd, close_extra_fds, dont_close);
  2698. + }
  2699. +
  2700. + return do_init (event_fd, pid, seccomp_data != NULL ? &seccomp_prog : NULL);
  2701. + }
  2702. + }
  2703. +
  2704. + __debug__ (("launch executable %s\n", argv[0]));
  2705. +
  2706. + if (proc_fd != -1)
  2707. + close (proc_fd);
  2708. +
  2709. + if (opt_sync_fd != -1)
  2710. + close (opt_sync_fd);
  2711. +
  2712. + /* We want sigchild in the child */
  2713. + unblock_sigchild ();
  2714. +
  2715. + /* Optionally bind our lifecycle */
  2716. + handle_die_with_parent ();
  2717. +
  2718. + /* Should be the last thing before execve() so that filters don't
  2719. + * need to handle anything above */
  2720. + if (seccomp_data != NULL &&
  2721. + prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &seccomp_prog) != 0)
  2722. + die_with_error ("prctl(PR_SET_SECCOMP)");
  2723. +
  2724. + if (execvp (argv[0], argv) == -1)
  2725. + die_with_error ("execvp %s", argv[0]);
  2726. +
  2727. + return 0;
  2728. +}
  2729. diff -Nuar flatpak-1.0.0.orig/bubblewrap/bubblewrap.jpg flatpak-1.0.0/bubblewrap/bubblewrap.jpg
  2730. --- flatpak-1.0.0.orig/bubblewrap/bubblewrap.jpg 1970-01-01 02:00:00.000000000 +0200
  2731. +++ flatpak-1.0.0/bubblewrap/bubblewrap.jpg 2018-02-03 21:26:06.273233339 +0300
  2732. @@ -0,0 +1,143 @@
  2733. +ÿØÿàJFIFHHÿÛCÿÛCÿ´ðÿÄ 
  2734. +ÿÄÿÚ õc6Mø‹5G?¢orŽ¹y-ã=:I.lÖ¯Õv+Ü�jŒÛóJ¾¤ÇÒçNØí„�1%†=õ¬U É®ñ·¡P|5q6÷š`: Ýy/M=.qðÀ$ÀÇ l_‘ŒÓ›g7ù}° <
  2735. +DoMœ€Á�‘sÌÿ_‘ê�ÚVsf5Döj—÷s¬ñˆ2¥`w5^.Ÿv¶b'ÓdÿIžóȯH”m†XŠ3!‚”e7aß%½QY«š: x)¯ÑÁ3ÿ›ÞÏrah_×±ÂÊRZ™¯*ÒP·)E­ ˦àá•Û¦Àý7È.¦K6 q'qÂçäÛóÓÊoÒ‹¬jØ9ª»°¬Ì㱞õ˹Ná9SjR¥r®UÅT/вa:îBiÓeãß{.ùÞ¥ý+ÇõÏ[5DœE<«<Ï‹s0y�Åæeð®}õFË¥a|áfëæ¡,WA[HI†Ïž€×¦u]ÙR–Èóú²ÐÆNÎÒd&Ôî)4+}½‡é¹Áêi÷3W7ÜW"Y“Ïèf?7¶?›¢•«
  2736. +6hôªë=Œ¡Jyô‚÷f;iBéÓÑ©©é´V9gÙ­bŠÐéÖV©`Ñ�_læï[3ÖãÂ6<V7ÃÝ�énNóÚXKËo¬ÖãÐ-äêí:¨f@ÊÑÐÃ3ëXÍâjkÔÐ>³ `z,R5± —£`…gÚÂaÆÐÒë6D�/ªÉaD2dg«‰ ŽGŠRYWGÏ1ºÃ¡k[èÐrÜC:õK"%üöÖãÔø÷³Å[ºBþ~gßÈØÛÌ|dƒãM†ªl˜™Ia„�é tp¥Î!•µøG¡nuX&!ìKµÛ˜ü®ó¤GNhÒ-°™Œ Ž:jç—p5R>{mG£Añv¶T²“�açßzìRe[xÉW¥ö­O0!牮�P-d,Ñþ½ww~��Q¸æu_º´˜vSdcB<·T¥Õžgbï2÷vÖr>ß”oŸKþƒãœ êÊæ!AÍ™
  2737. +àlF!áf%hQ¼‚¡žd¾žº]~•µÏŠôO½œææ¥H‰ ð°™�Ãk;<»—xšLKô¬k1YNÎ֩蟵óÎåšZ‹�+2|ÄŽë A&à.\� Éa�pÁ¾Ò%BÇÈïôe_Õ>¯Sy[OEIOO>¹¨:3,a¼M�TŽ¢³CE±hÊ·~�äœÖœ%/•p˜9˜qpõ:
  2738. +vpi);y˜$¡ÆC´¾Ì9!ó¿Xݲ— Êϲx1Ë�³¦V—etâLM,œ\¿0ôƒ4ÔzÔº'Ûy–‹"dp­ A+‡ÄÝ‘‚ܵd/îVá'aÁ·sÁ¡Ÿ;õ6ý>7+gÛq1VR‘k>”oeTóÛÉúO5uóïå/:vJ . ŒíƒêðÙ�ÖEÔµ�Á Ë ©105­ÊÈý¡\ž8‚8Û¤ÌOš]Ýã7´ã+.ÀémÅ€•Ýʾy¨…;)f GÞÃ"?«s”ëjŸK‹¦ö¨<¤*Ë»‡è8\âI÷-ZΊ’¶ž|l8A–ÊÜ»óº'Íß1}>Qzˆ\An¾IòßK¬§¥ƒ=ÏÊ™SÐÿ;§ .T�¡–}í°ô6�kžÒ  •ÉÊÉ„ Î6!²º‚RèQ 6°H‚¬/r7ƒ|í­‰².VžµÁ5o(ô¥!.ö[+Ó•Øñ¿[>zßM4©½™¨8gÀ&sÍuM¤­6}jpHeñ3CŸ
  2739. +5à¯Ò§qö�”ñÓ4ß–xÁk[ͺÕýÎÇnFÒÊÈ®=y·›­}Qå„=Þ}Üû£9$*j€Á¢¦RO1b\7ðJ 7¥ƒ*9º³™ÝŸ|÷© ÌتÑó œ{9º�šr–3ѵsí[jçÖz¼]!¥VG2æJ‹¡ƒú²§’!€„ ¶€Œ-T:¼éî–E¯OÃ?A0ÞèšúöÔ^kÖ­w¼©!×»ÎrÛ\yÕÞÞ‡5¿¯@åë¿™ïàè'˜‚Á6¦ô«†‹„ƒ¸ÍGÂCBxÏ—†ÆÔ©]ÀÂì4O!>5n#Ûn®Ñr:0µDµ)2l(rÕi€t.÷_ ˜³òb`’Ô�sÃÁm3bï��ƹ€^+Y†‘Ë!ä&ØLœ¬ƒæ%Œ† ˜ô›wE0ƒ1v]Xä÷Yw\ Y÷�w,ÁŠ£üJf¤drAm53ZÎò",kNèVkº:4Y0üH»Ñ�š-¶,]QAvm´ýÅ>™·Øj«a]¤dIŸ��Ç5\ˆ$P§»dGD�¦?ÿÄ%!"#$ÿÚö¾k¡í
  2740. +L†¼ôXZÃVÿ{6ŸÒkïžËR‰çlÃ@g¶Îþ.ˆTr³Ð¶nöõJ²ÎgÕ�2.dGÐt÷œª� %óš© †¬kÊ-AùTA`LO„^’3ö»úÃL­¹ÓëyŸÎDP9Ÿ\üùòor‰Šv¨ ¨EÃý·Þ )ö"?W¯å%¯ü„ÑÉק}ÂY‡O¹Çy™°žÍuò¯£œŠ¬³„ÐÍz:[7¥šêìçÜ×8‹S�;AwWû�·¬B'à[ûËÿ5™')óòƒ6P&IÈBTmO4¶HžÓHÒgé‹ãºˆ(ýªÈt„1ý«@oòü€½Úçò73s¡Þ«^Z‡C;Ãaê3T,¿�€Ð“í*³ŒsK@Ö­>©Öhoár ]{vz5ÉXz è•ûƒ -Iš0i«C^Ò]ª‚£íVåMƒš%4®“¢Õ¦¢z#?7âà :¶!Y¢Ã ª8¥|ü±ªUó,Ÿ©HéF1/ù5:®^뛆ƒ£k˜zÖ‹f???*)Ó][dÂÝö3òŠD2‘þp­ÖÛؼöÂiW)´ý‹UJ#–%ç9Üïb�s|ØXJãÅYMqu›M1Gú Bð\�gÝßôÙÒ—>µB_Ø&½âÁ¥ÌÅjdò'y~)Š×ŽæóÇ}|Ä«êiöËé1FømU�9û¹Ì5G¯F²Ž®ŠV±²³«¸zBßO>ªQ/}ÒNíHTXô»ŒØk[b¬YTÝ|úŽ!â áÔ‹�+-ªQ^¡ =G´H? A^´“Ck”¥•è¼5¬b.®Qžó#8ÙÀéìü!Úésy¬×K‡¥ÆN²'ÓtºØZˆoÛ<@GOIá1k;jßeÊ;ŸöäÈïçhh:øã˜gV0±CžŠçÑçüçMA¸o_] $¹ÓÖ)‹Ÿ“òœÐ._×±ÖÛr3ð#KÄ°¨ªÝSÓö|ÙÚªkŠÔ${üë÷œ²/¿¡è=?(K˜ÐðŠ² ›©ÎlÜ=‰U7³øÚ‡>grFO;TÁŸ˜W”}=Šå¨ãd8=hߺ´XvD1� ý-oÉŒú78lŸ>_ ž<ÍÇ¢ ƒ/å%ç�ú½¯/½žö.–•æÒà1ÓÀ&‰Õä �gŸ[QÿnuÒ{5£ÎŽ«—…˧|ÁdbÃåÖù)€* ¬6›²ŠØ¤NP(Ø"(U;¥˜é˜«%dË@¬{
  2741. +µ¢•%üêò×Ø[;• ²�/ðó5&¸ÒÿH«ÁÿÒ�æ¨ÀâðU�^M°‘Á-S5ó¥Ó>²‰s,LÍ™_¢…ÖÇϵÕÌ猉NѤÙì£V v5Aig10Û%ÿ­Î±ˆ’ g’ŠÐn‡aZ]"°Y Íêë
  2742. +ÙlöPûK"éDºtŸ¨�*A|é‘t;¥C0Óz6¢Ôz«g!—^�wJ"9Üæ¿«¥‹ž|ÝKÒ§=¹÷u1[Ñ3¿ìª÷Σ·û“h"£®Z sË4_ç †¡uŽˆ˜ -å¸Yvþ¨ùÜ$”V#üž¿еcw£¦vx�·`é<[°ieó{ª.thláݤ_ãv“gšQ¬ôî’ÆyQU—ÒÍÔ–M_Eiâ)2Ùº$WGÆÍoÙÚ÷¹ 
  2743. +jÑK‹Aì0ûB™ `øëš�>§Û"óAÐ�
  2744. +�ÞœÉ[Ø ¼ßz}š~;cûöÁË{Mo ÉzWö2¸Df2ŒA¤µtÇ®†O¸¹”^ˇF÷µ~‹uiÈX,[Ï׺¼ýJ8Ûõ‡Gbß}ª›AôËOàùI¬èAá�œ³ÓêÞ.jÍInQkˆ70ׯO¡íT=¶¥¯ÐölÌò*\YÔôë¡ù7²yßbˆØk¬ÚÎèE’Ÿ]Þyª¾o½žŒ!÷þÚ, h /ÿ]LÌP¹z£aX,Z}·=©k¯ìNk¬éVÁ8FEû…ŠñKMb�vçÆA'µôÑSQ70ãöGÂ¥¢§ù3˜*¥{'G/òζ¢…«Üdüµ5vÌájò×O€UfßJµQ…é26D­Ôk$ÛDÈX–¦Ó†+cy¥p;ziÂãLd‹5E¯¨Š“«þÏ9�,¥%Ê ¡ä9˜e6ÊqðŽ©êª,}}V*jäXGO; —åPxm¥ÚâtÝŽ‹9{ZÚmNcaŽb‰œ®{·Ý ˆ$¼M­PºˆRôÀ‡(ç ˆ«¦P�ÁÄ–ßr. si>(‚E")�¦ÖGÚ£(«FQ̹jä&0Gôo{iìŸgŸÓ é» [;Fß‘5�£øø÷ü�ùëó<Ç.n'Íž²—[BgXÜþz×71Éó†>þß)ÅÇÿg…¸†6xA\tÖ™2&¹ÖûŠ�&·¡öØt¸)šd’/îù�»@|’OŒf
  2745. +yt%Íe+åÇÚaŒ– “íWasY•·þ”EÞ}>Ç—&‚íb‹Í^¡R^Ý3$ð™zÛ¶_›m3g§ðó·^��—Ùfc~¾{ù©Àü3S3š1C2‘$ï#gý2†�âšÒÇ°xŒs|=â­à¤lè±òì_åäÈ^5Âôr(ÉwQKUXTK{H}`´Ÿm¦\7%•MþÒ3v{e¸™ÄÑËN€ÖSW=žC�éÝ=qÚ)Ï.~ŸXUŸ±í÷_êü¥¡¬Q‘_�hþß1R_ïÜÂþ%V¢¯’³aS#ÿ}Çÿ�—q[8
  2746. +ýjšz5_Í~Y¾³øäÜèt´ïªVl6w–Çü=øÊsžßü›~wYÛ+²L~q™ÍÉÍô®t$ø›¥& X½©X³W™Ï›O›—‚.Ø^o¡ïòV%"�"°Ü5ÓÚÏÃ%ƒwŽf©¯�Çi,¨M»×pvª 2ëk4ÖvgÛ\¼ÑBã…‚Öét!+¹r\ö,+h™1=�㿵­Âö%¿p:þͧˆ½FÉ®+‘Ù±mðýßBì
  2747. +´½åafŠÛOÖùßý-s3d^È:-²�¦ªÝkrTurô»éÒaÕ¥ F¢j«k8‚dŠfÿŒÜl8 aØL-}V%y¹/XÌf‘H•o@±R²ãeñô¯Oÿ�‚!?a¼ÌÜß*T³{þàX®°.Ht+˜�5›¦h+}ªÊËF(Ãáq]µGp¨¤^I#½tXø¬bÖ ócÄ’¹˜2õ†…Ÿ[ø+QBc)Zb³JÚ”º.*qj\‘Wìùê°f—ýŦóá‰òðÆýPûKbr9+/øï‚Äó“ð;ƒªî£i¨ÍXƒjGKù”8®k4†²Âe½Üô•Ïí2¢ã¼Ôuý²€Ó?SüÚ z’Óû²ZØ•9Ù7ÆŸâ¬
  2748. +„ò¢¥|'ù¡«6gõçÿÄF "2#3BCð!1QRSabr$Aqs„4T‘¤ÁñDcdtƒ“”£±´ÄáÿÚ?ùÆV±$–Xª|íbÖX×Õ9cÙoK�ŠÔéñHÖÆÛ++*Ù†[m•ª’I•TÓÇ��£b½UJµªÂ­v̘ðñQµjI$³b¤=ZÕÝ”Ôib’-£Q°Ë‘Z�kTµJãs&ìü¦�¶ç�˜fʬ$vâ4mJG2ÈÕbHÕ’Œ,6‹÷'»øl2äC%”üÄŠì²3 %—#qm(Ø‘¶ðјòõ†eû2-Ž$Òy b«Em¾ô³¶CV±‹‹btq,Ìrä~5V–5bLr!³q#Y|]±– ¼Qcò¬�Э¶Þ ,‘UF�¤cNµË}aYº%5‹#L¾¦ù¤9rîFeò–kÍ·“ ªY<!­ê•ú§K7#۸ѫHV¯Uõ�<ŒÃ~#æ8š´ö-€ª¬ùðËê™XÜi=>è÷V›&ð�shÚIb8ËoHfUÉHdÜܱVR¶$måñd‰p!åâ®DklFŽÆÊ3Uˆt꫉7á$jÅ#1“mŒÊËá�Ýæ£bÒ_²ß°åÄеe©
  2749. +µª3*‘íIÄ÷{zgº·F-áXqRMd²K´¾4m'Hç�jž“2µ˜÷ˆ¤\HÙ·HÕcÜ$�[QÝ÷|�µ‘î7È·L¬ZÍb9µ$™cÉ�V©¦jŒÎÍû‘j±TÅw²òñL~=‚ž_� Ñ«r ·%4nRሲ3q$ÖWÎôišIj{½r6\Š³F¬Õ$ÓÕ¬4’éÚË ½ao¹X·d7ª¾ ºå^B͸˜•i ¹U~Ä“PÑâÒjLZ2?Än2Å"©U]»xC2³X¯ìû»­“ôˆcªU�Æâ±›’·2I<”ÜfÉ�?+fÄÜUä,ˆËs£NµÝ&ÒÕlu„xX»}"Éõ�Ë1V®Bê[Ä7¤®RvÃs²¹dtdÛEV=º•fËìJÿÑñk~¡rìêö¬¤väÒqRi*ÃMeÈ’[`n7ÐCªY"¦á³+)§‡m£$«dÄš‹KS^«±oX­q?«‘ff²–vÏlå‰í*»Q³ ­µakYnVÌyj¥U±¼Íëv0¤-V°º…=ꤒ3 !íì�š6²�ê'f#Ö2Åá÷¦¢iÙ«¸4Þ„ô¥=ËK½)æ®àÄ+fV5‘½SrØ‘ªùIW,I*»e±²‘Tl·P’±â§š¤ym‹ýåk�¹dC 3UEÒÖ+2«U{=‡ØG§f4ñí®^°Ì±®$�çÒéU“ìbþÔj½ßbMƒ/dy ¹FŠ2ÕŽ<EZíÊc3dLÑ �ØÅE$o1_.çùйmª™)ȇNÎC»­”ÔLìÕìU°°ýsgÊ,m‘­²r±6R÷#iZL½#¡ªÝéï
  2750. +ØÄI,R ¶™ŠÍk1_¸µ·o(ÜlÅkˆ¾›±Ç½8î:úÚ¢<V3óvulmÈÖHÑ­FçÙ§U¥�•e:¯úR6–64ñË! kÝË?¢I2É—ÂŽ"ó5*ÅRÖi;8ŠØÇṞd*³ ÞQlÄ‹æl±¨Ùm¯Çó¡[Ãk‹xPê…\¤+e•M {kÖR+6#.XŠµb6Š¶R=Bƹx§æ<�tŽ=µ¿«ý’5m¹ç”’míºÆIÉ�¶V’%5KpIRF©Ç—dmæQ¸ÆŸÅfÅdÍñôžZ©ÄeUÛ=,|Q½O�¤ã,Š2ù…å‘£‘|Ʊ‘˜�­‰'.‚9–<wšË‘Þ³wB´«-¥!šY£’¾)6ž]ÙY7…‘¬I2ÔVò�dÊ£s8‹ZØÜEÄVo1oªt–ô”VQ²â-[oø¢µi,te�¹ekȶ&�U·¥‘VBi7 :«c¶I§Q#�rŠ>è[<±«Éþ§ƒT±Ï�ì'Yõ¾´ªé¿D›ù®«ãï:ËKþGÖi Y5SoiMD›‘I´i¦Ñ²íj»’NŽ­�%Öÿef\bŒÕHò5MÆV¨¹ nñEË—e�-X“§ÉÙo¼k,G©VîêGÞ
  2751. +µ.GU²÷‹/„LµÇÒ7e©½±Œn5ÜÙ«V<˜þJõku\ú–i;©Î´ëí,+"ÁßJk$—]ª“U,›Är"Ë]ÃôZÙc¢U·‚MVÉd5 f•…ùZæ<�³FÝžZ‹“ “ ‘_¸ö ¹H¥·6a[ �¿ø¢Ù¹ õ�ê|šE&�Ýå£[wìHÙ™|Nè¬Jѱº.7ð£u†©[ksUµýô£PÎËY{ŸõQ¦~ñTU¤^2­B×i�xUå&X�#
  2752. +«[ ‘ȯÜG Í�”UfåÙo¼è¬†iîIŠ¹b[ë
  2753. +ßTê5IšEnäÕCh²“½ÿÊ5‘c¿r$‹ UdU“”gVª´²1×­¬Ž(»éö�d–QVÏbI6ÖÛ†£¬•–± &%ª*³-˜l±? ÖcìÕK5…Uâ5‹7ÇøË#ÚtòU¸•À_R§âc£'PÍî+Gã‰b¾8³7-®è†e“ˆÓ-q#Õ6•d—þWý¤ÒÚ9}ê›QÅ1&ª%ïV]âmSI‹HU¤j½ŠÍZöqDZY•†QZ«RK©_Ú5~>?úL¢µXµxŠÙfâ+yXÑêK=”ÖY`¶žMý$ÅqÄfÛ–ÊG®•š5–1—ñ6¢(VOXšF‘r-V±#YˆÛlÊÖaW¿Tö„’5U-÷žZŒYXµFȪÖª®å½kññÿa–Ì~/�¤²ù{“sãã¤VNì�U¨…j²�"È7/ê!ffZ¹4ÊØ–·)kb{;Žƒ%Ä^?xÕKb5”UõöYªVÅ•x˜ÆÕcËÝŒ«f?/Çõ†¯5,,Œ¸©¹åa›‰#[+a”n_qÒ[ë±ì8¶Cb¥WãüO`͈§!±-cËñôv7Ïì%éötéº :q™ô�/G°^‘xÈ7�»±°o�O�bFéö{ùý§GO°èééúO×/AÓÓœcr—ÇÜt|�ÞßggGÈÿÄG
  2754. +"#23ðB!ACQRq$1DSabr�‘Á4Tc±Ñáñdst¡¤ƒ„”´ÔÿÚ?/<–ïn…–ÂwϯÖÉm²©ÝÝ (»XLiJr¹L1æʆ F;R—HÜÅuäòÄ» jJbbÅ)iñâd®p“m>ÑKqïE.!Œca2Þv&$ñuë‚» ÐãDÑÐQïZÌfÊÍp7Z­Êe>°!jÚ2†¡N¾zeël·è–ä¶pöý‰¬–L¥hŒ¶ V*ªË‰½Ž¥js*%˜-[Ub5�)Ðj‡†*ÑVYP’ÜRÜÖÅ’±V1É%¶è+"S¢×‰‡¼°J eËŠ/ s#ææ”éB¶¬—„ÍÔ(7Ý8†ÐóuÖÏß ,´¶Þ=uñùeÖÿ¿?$heQZ†A""Žô±–ðª¦.²©!hÌB,Øx-Œ^ ó#„’û‹•43 K•ŒÄ.\ÄÅëúù=Ó…«·}*†áUª”+Æ& %÷r²k —.´¿Î‚$\QcìÇSâdÏîÒYo÷*‹î«äo§x!(0Wib͉£Fž´BáügÙëðìâšØ„Ql¸„£ ü8¸Ð¨KŠ Èr³{
  2755. +—›SK‹
  2756. +¡iG|ØUʨÝ6òŽÎv I·e*)û¹,áo�drâ¶ÙJ=ݬý´ªI!ʬà xV)|˜Â®¶aÀ«Ò¡¼üŽVU5Å�’”JSÓ©…lBc¯Ú·÷~�Çë÷M–ðyü½uûû-¸{5Ðî”Ò• †/�—Ê¥ñ/²·/y�ðœX°VlÌØšT«·Í‰¨J]F»ÒÊ…‹•„0i^²Ì¹P¼1YbJ†4‰vźê]ïïü¾>¾ˆÂÆᘄ‘b‡ÓAŠÈ+¸e¹mô°“›4MY†!)hÆŒkÞ!™ÈôY÷û¶iüö}Ûfž°,¾ŸÕï÷u·Í>´ÖÌÃPJ)Þ8‚+ÝG\?¤Â§ ±"õ~!báî¡,AWNð\K† sDÔ„]`—tV ¥*5;V7)˜Ø1Ô­$*ÝÌ2"¶«ña§óW½‚B¾%Æ ²žŒ\W ]8¬n…l!Í×^ùw³JØ]¥5ÂùlŽ¨ù¥A§+Ù0P¾TR…Û²„Ÿ
  2757. +¥PøfñNîF9cÑÉè °‰¶ân¢ê-+f§`Žèa $Œ$Œñu댧S¸—*¸s G6ðÛ..´A³Î#°fQ„CÅ>§Çü¿9wÓ§i­–LTpˆåRçZqtZ­+F&žÜЩÕ«É$ÂÄå/›Í•UÂËY‰{¥D¤Dqf©&ãåÜ«åQv—ÊYcŠÕ2Ø"š¶ådËÅ×õ…š_DH¡ дۈsëB,·M>ÈÌÝlì(åÜ-Êr"´—;Ÿ]h‰HˆÛ˜K¶[tr„†Ò•H§Ž£UÜÉON�S\_OU¹W_ø°I®îØKÁ¤ëôZ_Ö  ¢¨?”ª"·,!k°Ô[•KÕ M±|7EæÍΉ JhXÛtn‹³NPÏÛ§‡¯Tª¨U8ÜP«�Ë)ÖÒ›8fÙÅ.´£2¹Ø¥—ÐŬœÛš¿ô´±"+ÌÝõ_ÉieUa]óÍÿ‹MÿÕþªR�AUSw�ü^a—G³̬&ÁeÃÒË.æ ØÝ)ïg¶ØYJ}™õúüa]nnºóvi•UƒN7ª¬ï�ÍÊ”t¢#wc
  2758. +Ù‰î˜�u¦0‡L¨&ŽQæËLK  l¡¥,/•º3x,%A§%’È¢êO¦(²´rÁö¡Ç ÅlÊ$±šfÈšqæ”Xæ—v\§>kîŒÍü:õ~z~��²Í|å]…éf­JœW"ømì9ˆBPK4q 4¬p¬r®T8·ˆ¥ï[ïÒ¿ZªªƒJ)m­ß7þ,ÅšâiGNEUmO^¹Åp•ÅD›’0¼1kå”;ͦ™Ã›²ït,¡6³[;ì)ªVKVh²´n˜—pBÖ“'w(ÂŒÞ)–Âgxm¥¹WëQnnòŽ‰|ï•A¥U›s7±l%·
  2759. +/EolÕ¤ÖV\ßMn™K±ÃpÚPG{`ÌØ}¿[¯_`–{
  2760. +£ëÕ6˽¨$<0¸Yl®§nó
  2761. +Q-ºÜ8ˆ'(¯wn+à�¥•‘‹Ê1bJ´c–¤µbÖ|&©XKR‚¤J„Ü,!‰¥+®(î+æ£Y0ŠháëÕ4K³Z0—tòØ9 ˆñBƒæ–Ý4Ó ÍØSXQâU\K‰M¼1ÄK,Õ1uP�KÂLÞË”µ0Âk­tT¤ÊR_:jíqAU«t5ìøZ~?ãù}ÒŽÝeJÇ•5./zø4£§Á~õ“XR׎þƒZÙƒ…U«iQþ+½KQâf;f©N˜ßž‚#l,£–hŒ¼x{-ú%°xoáÍ×ò–û»OÒuç…äK®á„3^R“¶£›-/óa-¸ !dï·3* Ýu¸½d×7kêåk%Q(U½L£ÕdD¼]ÌI �^ ¨¸•—ÓF:°JÜ]ÔJjª
  2762. +Ñ^4ZÚ9Ir�d´,
  2763. +ŒŠ ›Å2°gÇ-Ñ Í ,á›g»FŸ÷ÑøiÙ¦eÒáõÿ¿òìÛ ŽkL¸e¼LÃʃ¤p¹xÒáIfæÎðNqpq¡jöÛwÁSÿuŒIX£ÝqSò¯‚ÅÚ¢Üo¿ÅL¤+&ócû8ÁAz9«èê…¸ªÜª:�®ád^X+â2; ‰/ÒcNwºî#á(D=‚7/j]Ë—f믢3†éÅ}©®†+!ßJv Ùy?ú±ÄIkwГÞ¢émö¦kfÑh²gVÔêê—¿r¯’ÊQkHyP‹-²œEÅ…‡)u5­[Z¸)öå· "ð† Â,)ãûàå7Ž!!¸rÍ°m)m°†[./—]­…oû]zæº[K …œ™N³Çº:„\_µ•%O˜·Ê‚›‹{ÊŒ¥UsÖ¢å|ªk*Œew*]Å"e ECX*ô2ŸU½ÅkW‚©GB„æïeÖŽi·°–7,ŠZ=YmÝ„"CD0†ìñeâ—{ûV^ÔËš[ï„0Š}a•I¢ÙKi>ÒÜÕ¦b]‰z÷°WŒ¬&¯Ÿ©T"ÂS!$„ZRŽ…µ¼V`Ê:USµ˜PV$6”¶1b̧>Ì"—{ûRãaÚPFRŸÃ!–Ü0FуÅ-Ï
  2764. +îºýðnõf‘Í-ñM‡×õŒ§S3ææœ8b0áP�•Ø{™OK†L/K-? ·Šm–ç¿°¯¿­½ž.½PG,´G† ¥ ó‚ElÎYö&»%Ý–�°†ØB"3?ý)âë×n„» Œ¶è±·1K­˜ƒÃØRÛ¡e‚W ÓÃsB/f×AÓL·²ÑÝ:vM»¯¢/dfˆP´M�²i^�‚4èòÀ9£4Ú:KGdzNŸÂ,ÈÏ6�±c¢è:;<=z£4fš|“Å׫°² 6@ò†ØSÅ׫³L)çÛ4OÿÄO "#3!2BC1RSbc$Ars4‚ƒ“DQa’³Tq¢£²ÂÓdt�‘±Ãâðó%5ÁÒòÿÚ?Ćb7DF•ŽæLÆó�f™D|Ù)$ æ>1¿ßðê( Æ™L:W˜qîæð�ðàKÈÏKQGS¼êÅ¢šR„‚+š?âsuO³œ™M`FŠ“¾\ÌüY}ίSði­6IW(‡~óÞuvYã]„Æè³:�쮸'´ÙÚš!äôÿ¿èétJÏlMba+tTTó…ª#‡…mbئñâår´;6ª÷
  2765. +QK¹þ¬^ 6â+88ÛêeËõt�£²œX+N2&ø$�,̽–ó}&ðhYeôÕ ¨2Äúz‘½Eo¿}¼ÌžNJ½-lÍ¥Urêãh»*ǵ*M5l ¥Ç‘`dV?¯Ío5Jؤ™†®êG,'Ÿ °I]J~X³57ò´šIìaÏÙà5vw*J˜0Tö•Ó=t­Ú júM±'/]‚Œf´�)¸ní ‘‡c*€Æà ÷TdÉ•M?K¤«�a�sªÈ™€qS«ø~–>«yºªE0‹]U…hH»1Ôûæ´]‰},§Î䱪ҒV_TÂlÍÓ ,Fæ¨[bÙ‚œé¾_U_ &»5(fT0ò²/Î<ã+•û9ä2&*Ÿ&ÙÎnmv*cT”®TF ¸mª§ñösQ2­Ÿ:š—-KÖ¨K«*‹yE“+J³T�ØòkΓ~//P)1¨9ÉD—|¼@xGð,-Å¡tÏŠ)ãzŽi‹(JuYÇá*ŒŒÿ#?‰«ß \(v‰S®ÝÆàyÚ-¼9<e“³äæúÍø¡˜ÖØ””Žâ)ˆÃyŠ®1¸õ ��Bs¹RÙÝT´HiÃλ²+'ü]&YuMDÉKªê&ù›ü£ò/‹ó[Í×k™5Ú1=Ö€øm÷4Îß&´¶–¢Cæ+-û?î_¬Â²˜‰ßã»Åª`/Ú›’_6ï€òë·©¢$°€�ñ,Ή£ø.gåéÕáR°©§š‰:@‹7 f%N>p²æ5>—¸Vªèm¢akp—çè2ÝMYM %Zb‘¼Gâ²Þ¢ý[5QZ“ 5ZA/%x|~®V3JÚITŠUP™ÚHÇNe„‹ð.í% ª|ôpìªió¡¯4~ušº‹õ}Ujj­“¦�%“PËÞš€@;M^p²Ü«ÄÜV°Õ­µ›5“ÀqXשl> Z§DøzzìGSKLÑš�Eç5¼;/dp0ý?KÒn«(kdÑ´j lBØ<«€\ï²Lö£7Oà³TDÖèÙUcNð ˜rJÂn^˜øªÖÔ7Höz½œAS¸2…¼]@<öóÒ°þ´ê’’}cC¿¾ç2öþå÷búZK©…°š}œ¤¸7 2Ðáåùñ1¬ô¯Òª‰'L��Æ&k#oTE'Á“(±Y1r¿êÍÕ]D :€aŽÙÝ¡·ÔM:[Ù›Êcª¢�Wƒ�Î^]!+$¦¢º3 R6Jä
  2766. +Æ“ZgŒÈ¥óq|,ËÕ=d©åµ”ÊXR^/:œÂ ËNÐ袞ªœj�ü›UÌÕS1TÊ
  2767. +–Ò(‚ 6(íCG™ÔÅÚ9|ÖÞöú™t‚¤Χ7 [¾]Àd_!ú�Zý.V�„f°OêùáœJ£ªÓM%žùÓ›r+êÔ‡ÃÒ£´ŠÐHYÂSãcŒ¸²‡Põ>ž€Ø±3[„ndwE�+HÿÊ u“‚>ÐPG¸ŒŽáW¾lâãü
  2768. +Ò‚Ø&˜.à‰Þ`&7⟈VÖ|P= ‘Í�D ŸôtÈ@�2oÞ@VA]¬$#lˆî‚÷ŠýI¹Éí•”7HÆá x<ÄÕr6€ÕÒ±ñI0ó†
  2769. +Zià³–Nw/í WåbÕCR袨U]³ßŸ€R&ⵦ °?£ªŸóuOFä&Š¥|SR@ÈÈ6€ÛÌãg3–­9sÊNóÚ�@Kß>P/#Ý)OXª¹2–ü{K„HO—¨ß«ùšÚtÕ#U@ s1íq�x½Í&˜»]D¡BѲž~ÔÑkC# ûZù¸¾ª¥öj>S`„^“CQR°¿…·Ÿ;ú‹åb5æj�©-µ@ª‘6¥*íw{Ö¹ X"ήJìJøº©Út2ƒ§«¤Ú5$ª{ný©BxéÌÖÅ1uÕYZ’–Ý'aS¶‘¤”¬‚*Œj«Þ>:v·h.Š†œ´*9jR¼²öfµµôiMIÓT Ô]ªó§kÄLf;IjcÍU˜[‡¤ÅÅ�rÀ§0jŒêDìâÈÙÛöe5^³U꜕¡íí¨ºÐËâËgKº˜Õù^“héÆ»)ª
  2770. +"Š¢¥ Õ=&ÓæìÕ/°rcæüW*—7d&¤Xt§Xš�]DªNjœªœ¨*ÛFŸ·²äíMjœjN.ÚÖé§SP;6º¢‰Û:¼6Š›BÚÊÌWÝOOÙv–dYËV5)JìƤÒvÎmu}5hÊ›N«Mz9æØMmŸMPgâZ™“²Òÿ7[ÔÁrj–ä¢�öò5uk[ûbi|X¹ªnS6ª¯-%½’­"í’5Š¨••DÍ=ß²Ò VÓ¸þb«ƵªÏV•aÊÕ:pŠR5¬›Þ8X<BÞ<†û.ËO“ü6én¤rùn#LÖ ‚è+ëÖŠ€Øê`U�E"ê‰\Õ;+h#!*¦–åÒd£³Á%],½GUgQ/%?jU-(bþ�ªÉ5�Ä8¡¤BÙ„ÙæµÀº‡yzkS~–nŒx–Ô‚Dd*¬€rÝP«N�X|J–·˜U›.Œ6vwVH¦b”@²šmå(¸ØÀã/雋Kínœ›‡•³å¦øÿ¬4Ãå³V¸ ì´yÕ²Úƒ–|ÅÌ°ô'L—NŒÏ&ÏYâºÿú˜õE±©e4rÊÊYË$©£´üO""îþ”ÊZ�©&Õþª¹d/ËTc˜»9YÁJΧ1~�«�Nl‡R©Hgp-i¥kÚ>C¨1ɪqÚ@ÐYBþ׼Õh‰{á`äÇóè à*inà©_Ueoþ>jþ.·Ë’*ý§o�ÿ|gñ40€ÅÌj¡ª'„øío{çÍÐí€U=Qºœj¨ÚR3Ú} r¥ëÍÆ=:Žo¥•º:”ìÙ tÚRH’42ÃÑD`¾bbùX�Õs2è£hì“1µÕ4‰|!‹òŠ@~@ý!koæ¯Gƒcצ]Æo 6¾²KÈBÛ×P�âê3µ~R´aIú7·›/æŠê*šÇÇÕ¦Gkæpe§§©V.–Ucj´eWII±×´VH$*~Ôk1¿ˆ¹Œ¿„XÖT1_”ÝTJ�î½�ʪ,Ä*WPÑœi×ÌË—â«–…$kG-ˆ,°‚p¥ÍÊß"v6¯'Hy9]Ôýj�·v� À¶ü¦’¦Q€ŽSûEë)læñò[ªÂà‰ }>$NO”ÒOf[¸lÉŽ—Lþ«u^›ñv�cΤpTm6R˜ØÞUiÖ®ÿMLê©^“Rµ7TÛ@©×)X8*Í’ÖÖ\Ÿk³ÎÃÑËg+ÑR±ê™�؉ÔÇ•mV9–R˜Ÿ!U9*fšÙöU‡+³v�/gd¼¢œ‘K'_Yú¹iÄj¨ë°ùCËbòòqbÍ—)@®Ÿ³µØRkÎhÐB è…ýVTeªmüæúZXm:ªsu}ACª*ž÷ðòC� jòdo+')\Ü©0ŠÂìt´ô´•.‘³“ûCU˜Ö¿äÏÙ»SZf×7˜­D4\¨4¹á*q®>i œ“úy—âë*ªö�8¢ž±«'•5(,8úŠKülø�U+›ª8]2×l±Õ{�'yYh�ž;:\̸µ5ŒËYZ¡Ü>÷Ä¿øzQ•JR'¹�1qÚ#g�ÃÔǪ…Q6ñ¼„˜”Ӧ¸¬8W“çúše Ó˜VE%Fz¦þuÆj W¢ÛÁÕÕÑ
  2771. +äVv4»n¥v S §UJ…D£?Úª…˜ßÕ+¶õ+Tº¥†$DYÉi üätèhâü zä[YNmà¦2Ë+]Ü$WøFt²tÛ‰’HlŒÅÀ<_¿~\_¹ ÂV“.¹Q7…Þï÷?ÛÕ%[ŒÂ`šw'ýÌ—cѧ³¤Ó)¸R^(Y‘Ü«L³qeü-�}¤ fµ˜¦šÎÙÌ0°�¹­ÔÕû&¾§wc¬&´þRRr3øŒÊ­ ÔQÓ,Öã5ƒU) T‡ær¸5;9ù‡©¡ ñðÔŒïšýý ®–¢B¥«™ÞÒïH˜oà ù|µé.®œ5´c†;ÁhÖ\ÖôúhÊ¿­ñ–­*ª›•JªH5·Keu"ìD]?;T¼ zËnš—2J¬8„ÍóL˾Îßœéú™>áÒjJ­©U]9M‰uBJËnôM†B¿¥ÚC›éhë6D�V$YQNÛ”Ú2ó*¡_RÜ|ΓoWômmjÓHQW\ü°"‡¡™Nåü³ñþªº-Ò“S
  2772. +�ªÚI=ž�.rM'IkLØ´›TôêìëÊ¥«•é*:À]+œ.¨`oŽ*˨2 üj^ªšlÊ®fŸÚ;&v=S×Po¥jù\¬U}3ãôñónü­EfÑOhìp³¤T€¶$±XD®�˜Àš¾búF|ßWS%%†fœUO‰GN–ªî�œ¥ÕïÕh¦4�?(Ô&7Õuøz�æåê\ÚÅšê-‚U-ªnàj §ü6r²é8Ø]Ò%Ed°m¯åÞÀµ|ί·»ríº&Tñæ ÞÇü­ )©ˆ¦J¿w‚â"?=š§ý4)ų…$.T�JÖxk õ Hcwh´jºŽ’ŒÛÍK­~�m®–EYLå
  2773. +f´í
  2774. +Œ¢ZïeÝ5ú§ÒÓMEML
  2775. +£TÒ8ŠMìr�µ½B`ËÑz±µ~—ñ¡©¬\Vö‰ÏJ·H·1Tˆ\ò >O!CùJ X¾^Â÷•õRŠU‘x¹?áþ ~Ð$à1šp$øüFOiÏo=ýè˜(2bã|]qÜÒù<+S4¤"Mu‰> ¤H/Çrª,gúÌZSjjGzÊã¦c›Jùð �Rº�`]û;y¿K¥¬4»5U�â§D�6GŒ8„ò‰‹ƒ@(ýÚËiÖ¤®òå°ñ‡‡Ógòµgd² ¥¸jMS3gÉ>0õ1ó|ÿK\(U*%ePp¨|ú'oĸ˜¥ò¼x¾.¢¥©9‚´f,˜Yñ� ãóý=U–È(‰ dÛç>f!§æ/¤y~.��ðS~â’�…€¤x†Åùÿ•ð•“N’Ld¶ð™�¸
  2776. +ËJÌ™�læÙª—%ez•Q¹ŠBŽ©îàµT”ày)‘OÅPÚ†sZÐÄœ¹;*Ž¼RÊv0*éÎÖþ°§2û]m:r,Á‡Š¡Y9ªÌjÊÜjÄ 3\Ü#JáË OƒB€ùÁg-µ f^ ¹}%K¨hB¥íi*´ù-WgÌ3°Ô<űªÊžsp±]«ô“iU,‰Õ•®z[Ð8æý�”N6^æ-§WùR€;cTìUJO,Ù–-¨©B·TK¯mÖ¬Ï#VÆ7øºu*ÜÊ.ÓNå*n ‚ÇZVrÀê•Š[;.V‚žw+TµêªU©k¦0™p%Å~*…81Õ!|¥©x»W·Â\%î˜$Þk6–ëL¬ÏPË1ÿÒUŠýOfZ¶…NY]g(æñ°n¨X̺Œ].^>’tCN†0J™%�ë+‚á¨+;9£„¹”üÞ>vÏ¥w)¢÷X‘T°‡tԽ‡éò¼LD² Œ˜1|Ü^oÁïÒ#llöÜ…¥¡QPtÌ«¡¦rŠÓ�«')]§òõIÛ.¥Ú c«ÀsÎà5“²1&°SW�|¬¶aÕ=”ͤÙô‡TázDZö ”­/8p9Œêéõ4µF§6 F‰"DL“\‚÷Á–“9~ùæÓRÊŠrršÇpˆÉ¼¼rùÃËK†äžénþèáðÿåê ªE(èÝ>�—ÎËzšS�'†«‚GÀòßä ;hm=¡Q�†6Ó2¨Z¨¯·¨Ïê7ëi”;€BÛ�»ÚjÜ~%¯ù�-3·¸2œÐ4`$Sg‹ÆÌ>.‚�"dîÎ25o�ò_³Tþb*Õü½X¥Áö¡¡U»·Ì&�É»ñدýäÕ:¼Ô@.MY.=Œ´øD¾™Ž«®#³mµÃ2Zi¸<Ó'«~],™l÷'tqÌØ w‡G fáÅ¿º Ì\Eý=΢#6„ªf{ÍŽ ÊG~KòzY9\Þn<ZÆÖ!pÀBƒ Çp“~¡�¦µåàêc°œÆ¶´ÄŠ–R@á@´9‰BíæÔur�ÓÑU.?k’ª§‚ïE5?'ž||ìfCN¬œ¦ÕzMJÛ¦T̨ÍÓk˜ÂÍy\¡õ�œ,åâR¿‡Êêäz£){¢i{üB¼kÿ[£äqDn´${Ø~êyÿÛÑ2˜\¥TÇ3ÚJCëÄm3ãÆ|Ìk_𰱪ХéwiäšîÅ"cÒ·©gÂøWèˆéÅ�L‘…³)†hS\ÒòqÔ)y=.W/Aɱ ,t ©xD”>ÿåêõ¨Œ6Èîg˜Uûžž«Ýt+õeh”�°d¼éM£ù`Y?pêi{oiißSµ�XMtec*[³]€E Æ-;È©û;èÒ|6ꎂŸ²0¨(“Vu´v€Æg™ÚÛ9†k·šÆ+” Äí*€i©ÌÙMæ¹(
  2777. +¥óªm¨mžZYz^ 6¦vhÓd}?g2‰¦§;ÎÑQó]O„
  2778. +�ÖwŒ; ÖvxGßÕƒNݦYÇkÙÓiŒ›’$Vô˜Aˆ¾™Ž�µÆE¸˜V*Hýæù4ªª�¤é
  2779. +–ç ›•¯ ââ·ƒ%Ÿ—éuµ¸áê"€-Åaá°È~îøšˆDŒTADEÁŒÇŠßÌ»@€§ß
  2780. +¡‚;÷ Žf‘~úƒQ9"ÍìNðû–/ß¿XÁ+´d¢ †è›üWÄÕqÓR0ö~R*wÂ
  2781. +e ʹ­®Î5 :™QÊì  å'›¢EŒ,$â‚% @_…*, ö_Çk?|>&�’cM27>­�¾ñ
  2782. +†ÀÆ>M~³«§¨šra5"Ñ)ÎAÒk};8ºÉS]¢7A0[¥b-2ÅeÃÁ釧ÍR¹�õ)U£ £-�CVµTmŠ¦ÒÒ•Ö`à5³hmV-Kg+�¤¬jSCcѤ{-eQKšl¦Q€öŠ�"<_ý?¥Á™Üæ5J†²™i¦¨Y4 Â¥Ø׫�ï]¢ÎÏO—Çñ²âª¨k�ÃTæ®ÌÁ:öôˆ�™bíøt­W£¬ÕXé©ë›Q) Í’¦¥>ÈM¨æV)ëª9¬Ç•½˜ðôôêdËûÛPT·Ê ×Í0SêÚ|Ã5ò©ñãæ·ýjêŽc* ¥P 16˜\ߟáh{±6V!Ä凕£fO3©ÕÊÔ…;%­�:•Y/à»ÀŽÎ|zž}S$Œ²àsq�«ð‰øóú�_¥ÒÐÊïšÇ½‘#ÀŠP¶ïŒuwåX½l��²ª«ëjN©ÙíkègfT%Êìù²S¹EÚéÖÆóhÍN«õu_Lš‚V×ÚU ¦P”S›. �UYû?Ôo¥ñ´ÍžU˦eEΪ¾¬eS„{6%ìçØÒ寕ñ´ÚãÚLjh:Œ†E\Ê4´ÆžºÓGùÀ¯OKe.FƒÈ¡BÙã1?6Î_�F’)Š‰nöDz1Ÿ„„½ÍCfq‘Ü£Ž§´Ï-Þþ�ARg¨ï()ÞAáÒ IÐJ�OVQÄx†¢Ÿ`ËzŸ�ê«W°[iU-öLï0K¼#ø<Ÿ V|ZÝ2ÍÃó{¿ƒM8á3.ã˜ûƒÂVßéñ~n¢cƒw²&îû?þKûç«{íßß3í‘Óèß™É;†Ou¾KÖΘ+ƒùšßJœFD†½¦‘¸Ì„s0ƒ ºtø¹·µ==ÔœTFì½�ÐÓPˆšÈéôÚ¦·Òo5ºÌo0luPÅyòi„Ò<<»8í§mb×J¦´Þ­›ÎË_Juuà­•pÞÓsWFbf4¢×5:]XÍc)›T¥áÊîÕUKO²¨;6Ì(s•H•“èP²q}£±lð ­Q¶¶�@:½©Ùªª©Tx�´(2UUU#g”Ê÷•HÕB R!­žêí¥gÕÉ]^®<©ì½%f©"xn€)¬xð™ð÷bÈÆ·ºKR”çÓ‚ÎoLÂÃÞ1>!§�Óô´´›¶ˆ¡cv
  2783. +Õ ƒœ«ê¥س¥¼‹í êõ\¥äj”ldŽJi¨ˆ�œÅ„aÂÐÇÔ´X¬kú¿WR–î˜ï"ºT^­‡ü®f]
  2784. +ê’I‚-éZÛžaŠÅÙæg3›ª—BVÅœˆÉAŠŽHî·Ó4/‡êå¿I92°§ ÅÞR/P?/O{¦&­•bªT�Òü 7›Gä¾í;öm¥Hº&º’£Ú†Êj|¶xéois2slÅéé;IÕƒ´ªj¤Zt�NTê>U‚Ñôüü¥ü¡ëijX8œÉÙé¯Dps ‡XjWð)˘ÍUÓS¦FZ£ìåÌ >}Êsi/«‰¶eøZ$Àæ$n·¼#7¤?¹ÕÓœmˆ l.g¼ÇåÓ/q\3ræ#¾Dá»ÜX= ÜåÜSa}üVyôåÓ šì¤2‹g�Ó»Îô™ÍÒ„�jââ(û‡ƒ^ñûÅß:ÿ³tF�Ó÷Ïùö–݉‚$¼æg€/ðè#![­€‹ÍÖ{£îk+ÔÄ-pRÝþÞ23%¿ÆMÄÏWƒáé ðÜ&"0¡"Uéóx<áÐÂiË9»z‚•*Ëjlâò,1‚…jc9JWEMȬUãkPLËVº‡gÔ�ÅI›'m®¼lnШˋ«Íé*¿mïlUÓÓ¶µÅÚ^ÁñT;™‚œ±SÓôµ³ë[=¦ñe>ÏAÎpMÖ&˜Z!ÓÀÇ·>—;ùEšBÈÅ#Q/Ä’·‡…'ã_Qmñég%eAH3qFò2‡Èzy×C+¡RàªÍ7¶lPbâ>e÷Ž?‹ãøzc³IBfNÑ“´Uòc—àЄӆ!+÷o9³Þýþfª©Ð„¹»B–¢�qÅ°¬éYà>Ú=+4–ÈCØ-\•(– Ço†àðdÿU©É¿¶^kJ,£¥O¤¡.£žÎ&h"'*Ø‘�Ó~]m¡WÛ)k*áŠ5"»
  2785. +J⬢ALFKËgU·æSrr¡³³QR�™KKOKybl8Æò"PxþÒ¿Ut� i*'iRÀÑT$�ì*‘ìd%Pî`v~Ö]O�£ ’¾j–DÕT^„ßKLm�l€#Ìæøâis!'N&D1÷0CÍóðh [»�{¦{£(îÿw[åk+aœd[¼cïÿîý§/~ñ™.ù/ÊÒ™ o¶]iEä)þ×Ý«§tD{g~í(ÈQiG¶|ÿîãýý:¦ Bšr´ÊLb.>;néßyt×—Áõ5ZépSläÜB]ªÃ­á¸ê¾D.ÜjåôƒT{F®ŒÞÒkƒblú+N£i9$�'“\}ž™ Cj*YPÅÒÐR¸êÜÜ4ÍĬŠ“gæ«°PTMC“L?ýÆ­G�‰EE­e%9½”èå)Õ­R¯H*ÑÍ´êDyŒ>
  2786. +ð=‡wÙÙÍW¬¬Ëj•Ù6{ÛJæ[Ú*•sj �ÒQ®Ã!_lý‚—ƒíjv,GE^ë JIH@ddvª �:Qļ�o�©kS­¡AØï[ uH3³¤L¬Z¾_ÓcUˆšÝl„Ôƒ(û :DJؼœ v_‡g±L_+�.‰-Þ­ÄPfb[—ópdóê¡]¥€¬pmqr¤L¸Dˆüÿ£•§šþÐk–˜Nè’IYuÁäáÉýý&�@IδŒà`.ÔÒ+ý@,|¾“Rjë-ºag¨·CÞkð ƒ# 1,Y1eôu8Æ.îÜ;æü:HE9Éå(!!�!+jïã |Y~˜uKGNy_שàƒòÚ]CÐC‚níÍŽÿ¤©$ËcÐm—!Ô�hàvkªÃ'ÙÌšµdÊߪÖê£hÐáNΧ­\ãÙðªdäM†¡¤³¸þÞ¶í{ê\Êêz½ž
  2787. +¦”µ¹„Ä—´tó¬ÊöäêÙõ9N‚¶jÆ­Æ© 嚯¨J{,J3�3ÒĤâO'•¬g¸€`¤ ÜYÿ¿¥…4îfá-ýì³Åþ–»5ûœrE;Çx·Æø�âSr¢}ïc>?§«#¾ØÝ3¼n›=Šßí!-ßÞÓUq n\Ä�Ê_ñ1i¥7H -bR;±‰øZÒòø™és}^–“°i¯ì”ÕUdÅ™q°ï6¼Ë™gr–¾o|F©HvάvyÂ$µŠŒ ä6ð÷2³#9ªø¸u²AÉENÞ©QÒÒ n5,ScˆJ’—³f¥Î#YVŒ™jššÚ�M@¥3o~”ÖÓRíê÷UJ—2ªç®�$aÙmÏØÒö«>U5¦ ¬íõ�—õYmJŠ£Øû"4”®Ù^à=«+¹w°”¼mj•cyNÒtˆ>ùdFã©><¤Ñ]Br-µ‹[køò¥´[tê�ꦤJI£P4…ü�CUcòÙêcêÞ×v§iûAµ-blJdT4ÇŒ?¥ \úšƒòâe=5+~®€ëf¡cJS%¾`ÿ?0òzŸ&† Üa�Â=ü>eú<ÏáhIå>G2-Vñò—ó±üFt¸ôüÒ
  2788. +¦‘Z1*iãI®+Á‹½™[—"¹WâæãÕ*¨²5§ŽHfî�—¦ºlœß³Ñ­T´ªèè» »t»yI°�å3bÃøkWÖË >à…Û
  2789. +hÉK^À.§WþgKÇùZk”£E7AÌ} ˜~Sy�øzƒS¡„f-Q$²€ÀxD›gßðùZíeP2Àþ¶[ÄCªm™F;6v�VШª­A€¡¦ÇUåkzfwÓ•:²tš§æÒ†Ö™¯hÒÕ4)^/”¥$i¨B‡¦`Ãåþþ¶…= $SÕHÔ[î >+ŒÙ”V¥üøµ´@ù‚\B7všª“!´<–ý/åè©�…‰�Ûþó/qÄHÀÎýþÍÑ#påƒ?Nÿ›êzº»‹ˆFfxe@>[}ýKOˆKÅo~ï›ðj¤�m§^¸ÊÀ•€ßß]ž²š±´ÐâÀÕ©¡½`>" ÆËÙ¤QÓSÕÖS:¶œe,E„ ûCO&l†Ñ[r-¼«3ruÚ7Ý_ i˜3tBNÀüx—æ´Ï«“[Xvs³ÉÙN±ˆÅ,¨M†XˆüaÂ+ÉøõWCú=F¥ô»(aÕ�$uT´çgkU!uöAsö¬½v-lßÒÏÒݨM¬¤ þ§9TžàR•H`¾ÍŒÅ¼¼x”ÞŽ%bV¶ivX£ÙT"²£¡3²¿Uü~3`|=RdrSNó\EAÈ´Íw$®3ãE�êuy'£Ø;ª^…@ª¿j, Të`^d"^ã:ŸKýn¶?èÞ˨I eH™6RÃS>0õ5²©é\NmA˜ÉsÒä�Ü^@g ÅÿåèU;·(X_}Îmä%ó¬î^O“WîBØÄð‡þ½<,[¢ž­0\»/>Êç ú¿ƒE6+gˆ„®Ll©qˆsmg�+ô±éÕ5J¦§Úɹ²d~àߧ=­zé컺ŸeRÛeÖ‡,ßg¦½9ËOi£À“¨�Á6WNöu?@MX$6E¾ö®’›§û{µKúBÑýaµ[J€|nÉGRTÛHEVCEõü^W+›¯ÒG:�¬­"CVBŠ®îZ![�ò—“/ëhW¿´_]±�” ��¡R¦âês._¹ªs§§«Ulú7›I\ÓåkÊ!ÑFv’Õ“àêjI .ËÄ2ÕDcòþþ©ÔÈä�Ä©Þ£¼@½ÛøÿôhœXǾؙÊÌ<}>_ú¯PÀÇpŽòhâk‹ÌÜ^@ÕFЫySR  •,ÞV@ø:@ ¿'ƒ–¶7óriÿ«¦¹¢òY%àÁI�Ó�s0TZš±^mådŤ_²Âžf”L š2Ï2î±lñý5j¡x—5”–à,GÄMÆϤÆtšµúŸôª¹»6²�E³ëÚÙ*Z62˜€²§ÁÎWMŸ\Ën±ìº´2�ô»…”ÍÂ'À-igã;9xýVž'rXÝK?F;üäh,cj0‘$¹Râ¸\ügT¾.c9Y@ÚîÊ•©­Úµ•Œ
  2790. +ý¡TâXe»ï>%z<cÓÈÜM¿H‰uA’. Ä¢8uE¾/M† ø™1+ELÃ*€‚LÒR®”šã.kH¬[×Ôêò¯Äï‹®ÌU'7‘Õ«s÷<É-i5I{œ–ãÆÌJðakSÊÑvI¥Q9¬I:¥£N¨o·´N?%ú·‡ÄÓәļ¶ˆ–êdÝ`¼‹êqS©~­ÿ¯Ü\É»Ûw—›VÞÓ¨™Ý!ÃŽ."Êá¯U«mFðãƒhîIØÒùgÁÒø\8*Q«qÚ.†Æø¸¦üæ°åþùêT+¢§Q“ •¡Xÿëv;é÷åœ=êuãÄF^}1@„¨.Rwþf–»5?9“׫tnÜ?
  2791. +ŸäÕì(˜Þ1¤Ùµ)«e›f«-rœ_c]¬S¨ ‹Oh0V&/ìÝ.f¨i(Ðᣨ¤MU*ï&½lñµ­cìézÀI�^<¸ƒT�‰…Ó²U%|K^*Ž§J�KébH}]S9ÓÁ]²v|Ø&ØS)jFõ ¯øx‰môšÐ=5Óà3²Õ�ÅŒ>>—PÃêjlµÂÀ[£ðñãg3G_Z†Çe§!DÕq“®!+øÍw—¥çäëîíçÞgîÛÇÀ¦#LUGhJJ�µ\¢ƒ:wuÊSM}.®•3N{9 §©£¶¢À[ûUNpäÈÌ­ã Øúº:m±´iëj$…äDb¦‚òÞ«¸òYð›gK[Nª’œ!¥@ãŒIk°£‡ÇŽðôþåj‹o©¶¢›U]GµèÕlBj�õ=[ù—¬ÉLÇQÕ wkõªí›±ÛµiÿE_P;8h–™ìW,‹:×Jú~&)• ªÅè«—¨¥VÜÛ{FŠP%*Ú5jhAæËh%ËgS"Ö®o7+SÊÑ06�µ­?lÅ·‘S�ˆ6ÏWQC´]N`ú+”Ûƒ�Cˆ‹?åÿY(6†ÞÚ��ˆ£¦Øµ�–~+šœü_•%¸r«EnÍ©Ø›0¹¯nÚhªªDÄJ¤¢æ@ý²¹¾V,<­ØÊÌ�“lûJšþqZA˜‹ø¼§j¢‘Î3¥2´—2ÙÞË\ÚŒÂöäÆŵYO�—š¦‚ ‡ÍIDÆøÍ”í·äX®U16a»ÛR0VÛáø~=Ÿ5 Ü7´Žw—”TAÌÕÔéh-—@›G½Ÿ6—%î(�ñ:,K:@ eƒ¾e�áU¿ŽÞ¦�/©•ÓÁ°]1#(hñ 4Væ8ð¼#äÔ ÷[¿¶w[siQº¨2«h(ê1+ j©¶® ÏÇNWËêµ:¢©rÙ8ÇŠœå°ªÆ-— OÆx>§W[9<Ì6‹ëÆ”‚ º”¤5*§!÷1ƒEy>)ý=QQ¿Ž(؉g;æ˜C ¨¾|aÌWãÓ$Ü
  2792. +��òüš™ÊÔ²ÝO�ûçǪgº_T¹D¤wnáÊCçž‚½,#Î0„ÍløEîhÉN\W)‘ÏÀ÷•îñeÓhÞñÙ”° ª¦pÓÊ*©ˆÂáë@s9�%jŠ£km`ý!ý!HáªM-`žqÊœjÕgû?§Ê³.�€eYµ½ŸJ«·Bj+ù"U,ÈXÖ|-mÈuZ_OXtnÁT›j±Fn5|UiýŒÆqT2观ðx¼ç£�dºK‰Î(6xßsÁ�ZOn ¹`7Žø q–Póü=AÑÓµ«=àÁßàáéM¬§¥Kæ1 $EU 2âÉàÄÏ‹gK‹²í4¥ÖÀƒPw8x®hrïYüLªþ 2è-ö¦-�áóX>û4ç�1Šˆç»pä? 4µ
  2793. +BæÈ�Ê-ñiñ“n 9J¶" Æð1·‹‡Bƒ\(†V3;ç�Ê:(¨ %2)nÝ`ÿû³EP}ÐŽð\ÇŒ´ú�˼Ó0"7Áê£xD±ÎºïÔÆñ’˜ï·¾.ÔÌFâŸêÒv}R¿V>·gš¦ ‹{e­/é=¡¾§*Ì]e·[+e×­©�‘P4ʬ§‚„›@1áÆ ághêµ^–¶ƒŽê]™\‚ššfpÔ4Š�wX¼Ù rc^_ŸÚfÝ¢êXMR°vP"o©�ŠÆÎU�›W&¥i’¨Ž?t‹¨¿©eÀºNÏ8eêò|]Rññꎨ
  2794. +:B-ž`Q?~gü-SW©m:q}¯]3qS€™uUÚ_EF�¼¹¬_jþ+±eßNäìê6ˆÄ²œs×0Oʼnµ¡ŽÆ#�#(TÞOS*¤(öÎÓu@ÍP;j‰›9$_iƳðämECÍR²¹˜•½ÁDlQ^«—¿i€™qª™ì3ÈŸ«Áè¯.±í
  2795. +²]к6¢Ï„†Å²ö#—�&%^ÜËÓ) § ¾5SVB¸Ë„»;�| ´}&øúJô‘&ö.ÕSoX”S�Žòê3›¦‹âøX˜0w> 0'� s,áhs=^¶-ÈŽúp"wpÄË�ç‰V»˜gÅÙòcn/Ù2©ÔMV‹fI¤êÆœ©‰Êkp(*q+ƒ!›1_K€Õ—WTºUX˜¶“hMͬüØ�ù:m^EsloF›U=]Ý
  2796. +ÆSšÝµt�PdâjŒŇ\KbÛãêèoݤJHO‡Ý¸ Ÿâhe ¶#S­;…‚ÛþÑhXÃaŽù‚!‰ò«äÔÍÊYŒù¼Žá²Ûµ3›Õá“ÝÀðñk>øß%Ç»ï ð–²H.ßi@÷L�áÔTìù5®¢á8 Ý¿Þ>°œ IE“uóÃâÕ·O·tF¤ }Öïù´�u5OgLf² ;.%^xÀ×o+-~•JkÌE%_@ª‘%h[yP5Øké­�]2Ð�§Úe+©q‡¿p¨üôçsÏJÀíŸMWEƒf¦`éÇ�ÊÃZ@Fߨ
  2797. +SÏÁ¦&¢ ÁJ„JþoºßB‰”–èËÞ©gåïiU5�{bm¥IZÚs�/´ SòÖ&ux=]†B"6�‹Ô…™x­óŸò´¦T!õ„Û&);Ík¨õ/eÄϪÓç+)­¥NÎÚ©tU—e(Q@ÍAˆ\ÛO–«;±Jä›}EkuFÌMh2  %=¨"«„À•PN?µÔÇ‹ƒøºŠš¤¦H�¦R•8|v—.�8Ìš¼|ÜJ<>ž“²ö’XU”hcé°ß`�ýa‹–¿|þ©ÒéZë”�_mB�¹<D¬ùy¸ýóæ꺞¼šŠUölEßN$ŠàÇNxΠ™Ì_5NSRÆå ¦:º˜¯�*TѪ•¦§ ¨•~LÜcùM±IºYíäRª‘QÚ��‘š® rˆs��–ÏÎÒÁÍ!™jä¦V>ò‡Ï�RrR×2F …?5�®ÒŠƒ�ýãÇýÏ•yÈa‹®�“Fs?~øÕóºï˜ÒFšØX DÈǵ–ðÝ¡'oÛ¾D£ß×%,kâ¹R6øˆ¼š:wH2FfFwØÏ-¥¬M2°d·ÀÎègͦ1POvC�æõ¾æˆ[_;¦cÛ6“[Ù§ ÷ç üVx?‰§% ;˜¢›£¾Â÷„~ž�LÕ­Ö•¥twÅ…å/!è&t×�³¾JB*ûZ^à3§�zMjÃ3X«"&Eóà!·ð[‹IZ„Pâ¸ÍÇvï?É�JŒ 6740»ÌçÁhÿÃÕZè9ìà f¡‰q‹HƒÉ­£FžÌçÔERäÅ´òäßq*ÏMEÕ‘³!™"pÒ¨äǃ”¢>fåsÛ—WlÔÖTÁ‚@*j¡ðy8Ô®˜d»â}]T�*ZÿÒ«,M=wÈ0Äù¤!ýgÌæupëþr~”Ä:±aúÀÈ)²¢¥íJ‰¼;S1TT) tµI²?RÖmU °6�YÎWæµA“ÎÒfFr¸4SR/�`
  2798. +á —›*Dѳ'ÚI•gÃÔ쪓¬¥‘T®¬Z§­'ÇØ88 ”ÏÁ¢©¤]ffð…G<ïuR�D­ñ=æ3»wÊC¬¶Í¡nòþ­ÁÐ7ÆélGàÔDÌqwÁD÷ê ÙÞÚZÝQ¿Ë»EÌ1ïÆSÜb[ÖCéÿØA¤'†ó·ŽîV�$~(Í'íü:Ýlîû£åÔ#Kwï6ßòŽ¤Ò™gpï‹cIÝ|(’à‰äU'Ò"#×êü_åjN¶^G»†ï ¾@ÔÕî…‚àÁcd\g‡C" Ÿí.ïשּׁÚAÈfTóMVønƬÈmáì$²w©ƒø¼žMIe²" x.Wð‡áÕ:¡ôÕŠ¹N`¤ž ý�…W­—°ý=WÖΧ¢©Åˆi† ŠÀ ª%y ‡Ìo¥£©¨¦(p´e…©ˆa—„G¨Ïˆ¿“Pã�“XÐîÊÙéÞ~5õ2hkE5T5 3{DjËù7 ü»ü+RòvZ^_UÌkTºJJ¤QT¹î«-øHßy4K©eS«#9V#¥�š¸Ýb€lå„…€*ýÍ-àp$  e°&6¿¹êiµn6Ú;÷‘M 6žCÑÂ7s· °Âù_»itÃM†œ5“75°Wñûú5Ÿp8,ˆˆ÷5þiï�{>í Ñ211òë´Son ýÇó|‡©ˆßìÝ Nþ ¶f'C)9�Þ(Ÿ&’âL[íÞ6êmÝ£Íîê]U½Œ`Œi«é™&ÈÝ,îOïûúE.)¨¥[âbwBï÷µßP31lÚtƃ#¬IÃMA¼×xØ¢·ÏÇn]ã-˶ýÑÜuœZæ )ä‘N(î–'€‹äíÕÔwðGywo¿ñikÜKT3Û+/ÜòhØjKfn1¬D‹cŒ¸ZMN:€5ŸÄfªrd¶VÚmëY‘€‘œõ@´LY*¬\fp—çÆ|9?Lõ‘Ó�w ¯ê¨zfOXr €|%m‘6x.tÇ|�O ¡Á©'î;Á‰ ö¡¢“ò—tÏ·\th©ŒæÉ∈ï’üZ�${möè÷ŒÅZ\$“Žýð~_ö¿ÐÐ
  2799. +fd­?í- œÌ™wnþ­rb&B7ÌLûuaË÷L{5~ù öß:»wG·ú‡^9Ý¿¿¿Û¡ˆû­ß3÷ëï»ÿd¬2!ßÞ€öÎŽ�*SOr c¾,ÓkÂ’¤Á¤µ“EE*¦_¤ƒoL2}M>¢h$Õu;H²«%¾ÙàÈ|¾f«o†;²¡ÕFÉ5¤¸…ZƒYœƒ`fÑ’�Ý-Z°ˆ°x¤½²:aVö¢'wŽèH_h�÷«·G ÷É{§á:xf�Ê1Ü3x‡ °œCx‘ªd Âó{áŤӂg’;à¢Ð÷GðZÌš’dù`N7n·Ë¦\æ;†}ÍNèÕñº7GtÿVŠíòS=óýzݺCEï]¦,w¬­º=šï˜�ê�Ú0Ç»»Ý­áº7wÍÞÍc‚¶x‹úõw|wwnÕ�†Dn†ÏŸX . žâ�ßéa›S埻CoŠ;çv¤ÏÛ­ûæíx¦wV�4õLJj’ŽÐ¥Îàn7Å·ýšý Û!-*ç¡wL`f "Ð8Gû5¶Šùåìæ[t^˜‚ÿÇTÔÑ�“¿»ˆ¸¾ùÓ�;ÀEò13ºÙÝÝíþÝ2?®G~þÿ6·Gtj¶±’rÊb]ƒwß;ŠÿP¿™ª‚Ý» ¶÷G~èÿó­Ÿ´"K´Â˜[û­Šù^ë YMa’ÿFéÕ-;bq™³ºf-öoÕÔôëQ¬Ö0ÀÆP}Å�½Oßß­ÛûµÅ¿þÿ›X½ƒþ—ýú\,|^ÝýûôÂ�lF‹üúî-Dÿ^– !6ZQ?xÛì×ÙÂ<#áÿ»CΤãÅv·—·]Ñÿ$Oß¿þOÿÄ' !1Aa0q�ðQ¡‘±ÁáñÿÚ?!5à€ŠyB>
  2800. +F&tÄZ 8€�[€x^„MCµ„±j‘6ŽHCØ/%XÒqe߀3Kô�Þu€J(<ä(©[‰Ð’õa92Rò`ˆq‰G(L¸4ÀŠÖ� ÍŽ:Öa_`§ƒæŸÉ Ï}ŒÈ°ÒÝ�ÅÞH®_£o@8z Géqà‘ üì#­4�°AÏG ±Ñã¡BᾇpwvŽ,â:ÖûpPO.¾†q-‰$B ÁÛÔ#ìã4 ð-:�H‘ |© ‘C,¡’¡$¾È&¿@Ô'ÃÍÈ„á±€ñÈO¯N++ Bµ-#ÁÃè9£C�EøiÀ14«8œˆÝÅèG.¼³
  2801. +ŒOG@(1 ·¥ñÝŽœCáÈ€°—�BDí¡+“ê^Íæþ¡�Þ$g -eDbQ“ãÐÂnqÈfðÒ”#Fj@«J€fpgÃ�ÃH‡³IM”ÛIÔð*åNI,TùI¬8~¸(Á@ª�3…Ã\Ì” àà凥¡! pÈI“ÇhñG�l¨Ì xŒ -“RÖÏ´»Í1‘;µ* ƒŸ �R¡Èpwæʉ‘ÞP£Õ?‡aiP'TpzÚŽ{�ªÁèGVìÍ$€Zkd‘Ó½h£!±[€”‰†€ ã6DûˆxHf–hH wZkT¥á-î„VN*Ž´é
  2802. +�ÃŽ‚m sˆB–‰f–ÐQÆ D¨÷Ë-ä§|ðBÊœÉ�PL�ê(zZáç"i€ {q±áäúGóíF`•Ð<¿ß¾Ã®ˆs–ÄÙäÚ<$&›ñòi§ìúæœ÷Æ£ió(žøD·�X‘Ï骘h²Ê">Ä«-4˜”qÀ,Ö±òdZI¡ôg‘ÁŒt=’l§«8—1ˆL/â‘èC#¹` ^ãÓ.PÚ£LŠ2½ØÌFÙgì Ñçå´†IÖ*Ò±Øó“7Öb+«6£îI€$­5¦ze‹\L{(Ø3…� Þ£'‘Kkº=ì8qf±!b½±„s;¯@§þÊb·G¬icWMvÚ>(p¥7xÉ�í#4£ê`\ú.·òh�¨G“2J)¬‘?#Kõú¼òÑ›ˆ+�­gEQËm¡Ñ$L°½&R˜…K‚…p Çï‰]n vÕ$C¨paÐ0­€š4¸gŒ³0Ã@%…’šÉW!0sP¦c;Ørû;œJU$·ùO$PÔ‡ g ­]2‹Ë€z×e¦0"IOp¨•Æ"™Š¶422§pda�Ý«!Éð×Ò+°XÅØ9…¥w�€Û�„YcA±ØM^ZÛiO&}m˜$-Ù’ØðG'ÐOƒ 'ðL7À ó�Ò45¬`&1ƒ¨Æ%�Ôå\P3^ÅôÙÓ‡cƒòb[I&¦,J x»�¬Kx9ð.j€ñÕE3•Ì�½dŠm¸ÐÒa–ÆR¬n_#Å9ƒX ¶ç>ºìkH‡yÝ›¨¨Kæ VG Cƒ Õ0Š5áB�”3!Ö!+ ö%2ÁM€ ŠD!†ŠBà'1qê)cqrAO‰[H9µ�dõâ0: <¼C`#SÌ"$fBûº€�×3û«³€#ÇåQ e‰Qž’
  2803. +ǃZfÑf½ÿH6„z aGî;]ùmð{v‚êÅûM&!âUa'i& ¨å‚KÏÊ!(-ž,ª«(Z�ŒÀ‡Ã_—ˆã€:ËO
  2804. +Ý@m=¬`ÍË6�ž‡ã²Âqâ;Žûˆ´Zrb4OLJBp¥‹d„«†/à¿ ¹þ _r1ØÞa‚ ‚üL%�3tk�â ‡Þ w ¢N-àFyd+Ïí ÆüˆhèT8È!¥3ÒÀ‰=>‡j”¥ ÏÔ<6äç^HŠ3›ËàY'<‚í¬DÂx„®eÕ¥¦¾C–ÊA�¼zTŽIx*
  2805. +F—J`�Ì q£’ÙI-¤0Ó>�´ƒ3;°X�ËÉ ÐF\ñ¸S@ï‚ÈÄýRý¡N@ñªá”Œ…8b &%Œsƒzd‚•I†§­&.Åœ’ 2„Ÿå
  2806. +D§Î2ăËé¸0åf WzÞ]K9ççéÓ¬Ö¥1¼qFÂ@„+½LÊDB}äÀH+– ‚r h„"IDÆUÌNÙ´„ºaû\Ž@ò‚3Øe å¸��LpÃå2õ¸-[!¡ÆÍ7P‘?Iƒ¢�5ÑÃi^Õj“âà†ñÌhpÛMÃ%AƒÀ…jPÛ U*›\)Ï}êØ (G”!Þ‰€Ñ¥öa‚
  2807. +^¿óטÅ
  2808. + ¸ÀÂHS¹�LšŒO€4G)¹@8•iä•„;ÓEúvrJT:Ø�Æga{ç G•"â®Eú“xTÞ)Ë”¥‡¹(´†ab�Ô@×Yné´�IÓSA°¸0š:»A$'t“¡U¡ì
  2809. +eE�(F´ÂÂŽ$Ð`X¡‰ne„Õ :¡á ëH!dè‰Ã,‹fÒ QBPƒÓD††„B‘ãÐ%ÁU½¤å–B�&�=ÄF9ö{Rш�Ò{9D#‹0KK¸
  2810. +8(1T‡ÇÑïs’H‚Ø"”²ŒÕ˜PF©£\¨åèȈ‡§ øHK–1q¼RK¦’Deât¶|= J1mp!ep nÀ 2^¼Fð‰ ñu/íJ—0&'p“ðOF®É1}!Ç@}Bn •4_ÐbÂÉTŠ$˜‹1Æ¢ÆqK•¾ÀF±_J� Ì`Ãþ3Ìdšk¾1 ‹<9¡`@E6¾Eà 8€}€ wØ@fþaÛhbÍò¸È>‘˜¤òêJTÒ„ÁÅíX¨�ƒ\0�Ê“ÓY áq�+ÚÖ1ÀcQ—Ý Æ‹làƒËX€³ëv±äïZCÂÜœP’OèÊÜâ•Jˆ—Û©ŒÈSÎ0 š&¼¤žyÂe“*Ú—Ñ}‘ñ+X8±Š è�#zÒiIHö(ƒÈd–ޠüÇo¾R—%*ÏÇÑè·Ü¾�LzreP1zy ¬¥ ò,‡µôqB :�W<yZä'¸ƒÖJù
  2811. +HýÑ3ïb2›‰B3AdžöSẨ�E�—:ŒA)‡ Dì¾ñÛ�‹š8ú©ä7,&W sCmZo‰ÓahÇðÅŸq¥ÍÔÄaC¥ÔÄ{µ–ÃÀH;ýeAIÝE( |!ETDUa‚;�§ŸmÁµ‚-ˆ•9çÑé#É”3Š‚mp‘Y-cL¤6iŒ�¡áVTó�¹ž¸" ädB·YK$аIm2°•ä�ˆ÷ê€Û° ÀP''¿G�Ó(a�°Fψq¡ÊN@k[“´•B0bâ%cŒ~‹ ‰¨©Q�êH“†ï沄ûÌDwS U†°>rN49‡(=N#kƒ±8€C0‰jMä0 1Jx¦|ëc¹Ö IÄ:YÔ¤åœwÒHH¯¤”U˜ŠÉI�©È2Zª„ç�U€­Øª•�3\Fñ¤Åor™šÍ c� .Dxe)hÃÃ5ÜZRFM+`]AêÐwŽÆ =ìe(›À5ÆpsBkÚXy%ˆ‡P1 øƒ×q®˜’Udf7ðïªÊú¥1¼«ödG%ín-cm#lˆ×š¤"°  ÿQ§²G³°€ ƽîBHG~ÝnqYŒa�£Vã !Ôþ�Mc�î,½Àm˜èS1 n&G1µÌ%�0ºC3 ŽÀF:á³@6¨`*ä°ÝŽnæAž>f‡¦â¦¿¾V2<‘^8à*ýƒ:]ï²0P)wwˆER™…"À%ž ¿Ukm†™k©t”3v#ð Ô7δ‹�nI ^�æ tïÄÏ‘{ƒe¨ßoòv=—ëéÚ;?˜+1ØkDqúßø�Ú0GÚƒÒÙº>]ž’6ôkWów�lï¿toÄàÉ—½BKüè.÷%ËûM��ìÖÇþÛ\õ æC®ÝƒÛî72�~S}gæâÓ´5âßúÞ<µ«ÓžØ�êÐõG¥]}â�ÛÊnƒÕÿÚ ­±¶ ÷jw¼ýÂÉLÏï—^°b65"Ó–‡"wI"Á$hðH¡7KZ“ã­¨âá÷ž±:ö“s –5mÙðâÈåïÊNlÎ<µÀÊP�«fz
  2812. +}þš)ˆ"E’Sæ)Î%<zßÓå×D¡Tyá> g°Þjo”7FƒœtÌ£†—vˆûý'&ƒ
  2813. +DŽ˜U2Ý%¥%Ý$½®9/ð Ƀ�{N¶§3Î÷®G!�Œï¼é�#%�¶¤Ò·©Ö�´µF4Çfu€qB^Ÿ!
  2814. +M‚†ÍSíÝ0´Ï“˜Ö &U È¥§@Ã{N±<­cüÕ‘Œ–ªÿÄ&!1AQaqð�‘¡Á±ÑáñÿÚ?Úš¿i 2–/j ò¤ò|O*»*2¸ùœÉ*Öu®ŠC^øýr\w÷�y¹ìn­Ù†„¥á}F/ àÎÏ�±í‰™/ëO�†5&¾ ](‹\¹×Øð§Î0í²£wàSéØ�7¥ƒdÜý‚)nÍmØ7>ø؇ ½¦{ bøºƒBk÷œŠŒ#“cŠÊ¸<|7ìGƒ x¦oSYÄÛwÑ„M°ìZ±7ƒä+Ì©°“Å¥QÇôA“ír’n¯IJº=¢âlNð{ò÷^Ÿè<}¨Ýaú ‡òÌæl9íß)ç­‹‰Ba:cÉ~V:5Å$ÒLo¶\ƒÔ–\ö3Q�œSHÄ(wÇꬼEF9ô×q¥Ú=ŽìyNmMŽÛÉUDÞŽ¥]V`ŠU2ÂܨrƒìâœGáéìÞ̳GT6ëÔæ—€y£8$>VŽ\ۤÌJÜ#þ•iNE†ížoõæÇ&Žj‡˜ÖGȘpj4?¿d¹"?¶uæßz.�i¼0µó�rx¤ñç"�Ÿ¿Çƒ6·_MÞa ÏóeåwdLÓ192þü³¼ >)Mµc�š”?FÈÆB_6+uàx�ÆF0™9ü™=’ûHoŽ�úˆðpgˆV4† e˜¤Á–ä7vŽåçÛŽÜÅ £s»ÃDcš">P­Ú£ê<�£Ý_ä;£�tÑ`;Sô¶33¸õ~Ù­ìcêEXÉnCœ¾m'0~¹³Å,ÑÚ‰÷„ª 룷˜ÔFGC5>Š[s{á¯4;�'.K#Ðò|êýNQ5·ã_T U$¢^Ñè{Ét7LÙ?š-3ÁHž'Ÿž‰á¥¿!G»¬–È ÓIäZe]ƒNøÀŸF2
  2815. +Rh€�msCFÝóffÆ)o?‚ 踂cÙç o>}1É�лtIDìXΗ`s*ÙšQ£)›ëÙ{kω{«…FÍyùa’d =V6í4Š/Ýôcæx¡A³™âiÐÓ-v„Í=
  2816. +½=r""ê"dAn`õõè3§s`Ô͇òãn{ê\¾*ѺG½d&[,Ê®�‡ë§vYI$v+3ÂøŠ0pÔ�7*�¨¡¨ˆw~´J†ŠÏUŸ:"‹øsxAôvKÔn–ë9WЉ¾š�SûzN;øSM©oû„Ë–á•G!î´Kú N‡sv�v¤)a‡®·DÛ+É—EÒ(´ïùü·òŸ”úv¹V?„ò{Vóñ¹“ 'ÆŒ>Ì� tüк„ÜKtn„e� ø÷~#¤&VÒdA˜â@âî–üaÕ¢á¾åA¨{}ßpnÂÃc”½%åìä\ú$ä�z04§ëÅèå h«Öƒ_ÙÕÕx¾„H·×ô0»$yÅÃå�·`«a/ÎœÐ�ˆý�.öÃ{à }Ù~˜·îïød›6(›5X¢Èè7(08LË5 wç‡ï¸æ~1úܹÁLýPؼ©ÀÖ¼ ¼íIí!Ò›yg–*ƒšÀ±æ� ¬¼Ž‚Ö{�ï§F¶5R å·«ÿ6-gù㧼ÒcþşDK¾=Ñ؉Fï^´ç�0–> éÊ¿Ä_뺼:‹JXþ�CT§µ'éÜ0WÆ ÷Š~Våæ!ãn*š}xÍŠö:¢kd¬šºßÆч'ï®þz±�»F?Ÿ¤r"Ù�ÑŠ<¨×Vé2/{²‹à©Ÿ�0ñÛn§V�ZO« Åõ àîÅÖxnPWóf ­s—Nâ4º®s†"ÁŽnå¡;t]4Õ¢gUÄÜDWB1–†žÂd|{
  2817. +êú~ÀƒŠx­‰@¼�$²Q™4 3g.ùøc:»‡oa‹�A¤Ãï”c _äô"Ó°c:öôýM7ß²fÅpãöž^Oú*SË�¬Ò-Bä\ûþ8¹×ÕW+_&©:Y1B~H«\‡%Õ4apjàFy±VK­ÆÛrNñ.Ÿ§'Î × ²çÆërôcîM¡ß%�8áоÕêZ�ñ¥Kj&¼¾yʈ5uUöV"¹£ú¦oj¶aÁõ䬖ê</EÆ~1ûg…ÏÑSòisYˆlè"ŒŽ/5G…¼Žý§àyuùLU6‰}KJIª_OœØÿâf|z ™VÎ𛯠™ñèU:ýè¢8kœÜÔsy ¡ÈÒÿJŒ_8LÙ]R択 ÂÕ:‚�¼Wµòf¿È¿Nb&ää0gèñç1ul:µ N
  2818. +)0Ÿ‘èmtiÃç„Žt †R!žÅS˜ý ¿[â*3O ÌÌè‹Þ÷ò[j¯[fî{·Q™�Ô¸v(¡ªk�>ÈLv)zäD5Õ˜�þUÝêr‡‚Z�*+'å+ª†—µLo &�4×"ÈÍâ•ç>rAÅ·dáiÈ”£«Ó¶…OŸVd®¨ œ}m¸Ôeæp7‡Úø1©ãÍ%
  2819. +‰žK¬Ùº(Ó]H¼Fä¼d¿BxQ³%ñ‹JEÕ�$àÓ?ÔlOÝIã`´{ 1ndJœ‘ŽË&»<î Z¦±·TÝ~Iæ¿�&2µuF—hö;¿æë“p"÷TŽ?`û_ü�tÝÕl¸/Œ†àÉ>>j*–¹«I°
  2820. ++ÔÓäJ7y¨]yŸê�ÈÖ]û¸RÙÅWE~@:ÓÁƒºï[YA±Þ÷œçïøÓAÎð›tGÞØžíR@ˆ—jýrAÄͽ_g7ÁJ�ƒH†«Jj¾„DÚ¶6z¸³6Ñ,S’¿*ÍÈato*0ˆƒÆY± z0Ù®©§aÅgÇî8c�þ$ý‘´“ê>—”>ÌMÎœR6Ð]caèÛ°8ÿžÛvTLžõCŽ¢÷NÝìlÝ'�v+DæÁÅÌ9Ó
  2821. +ÍÙ_¿ÁBWlönå5‡0 Ô?—p (çxÔcw9+ü±îâ›x>FÌ}0¼ ¯“·ˆ‰¬’¶jëÿ) 9D›èj}}01v“‘Q»™±Àža½U½÷üW4?+´ž¢&,Ëwaú²j©¨qnLÞâéU”\Ó3ª’ÈyV)#j®:DʾBå߇}880VÛuì‚u†@2›øŸ“ 챧 ý y„¥%{šluQ7j&xE$”ƒë áLÓeÔópû_6'>××× 6hx¾-×ñ›_ú{ù1�Oñ+ôcbMeÚ— °›™édúËáîÉȺռ_ùQ3혭kŸ�¸Þâ(’ôS*tt|ºªû+\Ñ@ýÉäB›eK»¦)`fÆ™ÁP‰¬!ÙТÞëA•jo8Å÷:‡ó{ ²£ »©¼·þ”Ý¥AØñš¨0ˆˆ‰žf£6 †hÉ‹¶vêÏÛÏMT:¦Ô=~jc3�µ­`¥mÝ–xhp?ˆ„SLb+íŽ"!h`ÈD#ÃØêS~± Ëœq¯ŠIŽþYÏÁ/á‡(=‰©÷�±2O�Èí£g¶é�¶ýâZ:•ÐÖ~Ϻg¼dš8�xi;Y‹›ŸáÓŽXÃ7+=Q�d ãRЛíMq›É^:²>9�‡½Ø2X¡œÓãäÿö²FžÑü(@L³XOq`}k=ÜjAHß»1ááß»/æJwÜqÒ=´û-†5.ö@ùëf:£…/XÍ”ÚäL$LA—’ª²a…b©Lh2‘ ð¶*œÆKô&gÇ ‰÷¼Ÿ»vB<�v›K<[«É°3‡q‘¬¯kÓ¸`jÏ›G‚×%uY-‡1,0€×¯»ˆ*[«´aVcð»'v+—AÐúC=49¿�ÿÚžjQµ´z<(ËãÆáâŸIƒ iÝûÄ<Ûs@¤¥®KÈ3_&òÏHcbº–A¦Ñ‡¤ZÍä E$œ�ËǤÅQ’ý{{2ÞÖ�Ö—;¨ò_×Äç2Oƒ½?•ØU7B5á¾JPÔðßk†Ö�ƒLM¤ö‘ù¢Daó7ì?Övdƒ†~Ú›°2ÑãînüZóœ¥sÔÔÊ�¨®7
  2822. +BÑ�ýW¼l»70ãŽ#uö¯`|è¶Æ™�`νý´_rÞjõ€ÂÃðSctbä;È鸙yèŒrß°à®ú IìÕîö4ÐBÂF9^Ûyè·”šéÊ>õW5Í /¿4òƒkª°Uä7fØ»¦üx\‹Ÿaݺ1à¿®‰N·F"=¡žÙþI(�ºÆœÞ¨Ó…+i©£ò Â_´­„ª<.žC3ÝÙ5~Äd›Lîdz~{¨øY—±(Bèá�¢Ö#æÃVؤ¨Õ9‚'|~ée ^.¥jÔ>ÜݲþLìFšâëùÝFZ’øRþ{+løº-°BˆŠJï3È8gši†:qº?Ðô{�kú-ÙðlÑ*àÜá¾Û»˜,|‘ìÆ\Lø8žà‘Û^E–{›¡šÞ¸`‹º‘©×àŧj' «ýc×W†é¢#nè>ä˜Ì1‡rüM «5y�iožju7SSk´­Ú/ ñ<× oí7ˆŸšy*–Ïd±‘}2çÐfþo˽.E “
  2823. +sÉ>
  2824. +íz.¦ ƒ^‚¨d+?@É ˆ�x¹Ûؙα×&�¯öqÆ™HIÓ•oï"á‚ÇbOÞkvW�ÁÏ3‘©6;‘µn&üÂGõdž–�ùòÙk‹ô¢ ¿K2„ ƒêoWaD.eϯåÃSßçÆÎÝ�óXü›žaÎ��u‹ÕZ)&­«ª"�i[™#L E"fsÕ×ñï0å€.C¼Î›ˆª6”HR[ ¼²DǼy›½uv õ]œB�294Çë¿ÓAïò»vôٟϯsð5²�Ä®ï!á»FºçÍDÍ|KmDdt3SáØ¡£÷Ò>Áð¦UØX5-þüh{¨>VìÙ?—ö€¹ó:n2çÐðÛÔz¹ B1W\’œÅ3>= 1T‹^Í�X´ì2e[¿Êî¼ÌçXiŽÏq=±”†t¤„FÄߢ1øPB4O´8JË0��SˆÁÆ•UÑG°÷_à¨,èÌ…B͈A¯AîbJþ½ R?_„ pf‡%ð"Ó°ù[³M†Nì�²Ñf 2OK¢ð‰ä=ÔÀô3Ù©™ñëøHÿÄ&!1AQaq�‘ð¡±ÁÑáñÿÚ?ñx‰Š:õ³Â(ËT’ð-%¥R87@ctDë@à4Ê9‰)ˆ¤’PIP2—©8E0È�²f ‰êÓé
  2825. +µI²H�EÌoáv|z‹oÝ#D•¸%tÊBf@$I8G2¨_@:‹ªí(§}™Ü¤0÷½xd�É¿~Gí~¦Ò�AåÏ%iÉ�ƒrW=lýFê|ÐYsa3_3þD›°(yÂP.ë$é#ÖÅì÷B§¢Eî¹Ýôh±nùÖNša+Ì×Sü9/ܹ+–¾7TY49Q)vM¼AÉy�X§EäÚe¥c"=ù¢àÓU-d¢Þ(!×�“ò4òÒY'rÐés�÷CÀº¡%
  2826. +œŠ>T·=P®.€åƒ«´w3‚ª×˜Æ�I#8bn®¤«¬*z{_‡ætULþÆaó+±G8BÅÈ�1Ò*Oælzv0Ãø«]>Åc÷N<u3šþgç©J`º+dy¢S䢇Nu v¬} šiO�åVnøtHèü¥E+t5šÈJ’@E>&f§Êó:"Ñg¬ T@X�„@UP èÔ”„ŸA“ÂdRAD ‚èÀ—r�‚05Е()]�bHÄ8S!ÈUŠŒˆ ¨U&6<ÒSÖñ�wᣤ­%*K>3yë(ÕŸZBR0¬Ê8¬•S%p$¡jÜ^äiB™Uc¸Á´Ô~ï[Ÿ÷’'˜JPÔ±"„€JP� ¤¤ Ò³ñ\1l NY� A$„(p@\AV ²n, ”y›¦lðK¨¦”Û€¹é<ȦŽ»ÂùNDd„\!fx˜ú×–O¹³»Sö;—öu7­¢Û�3Ñ.—©[Q[„Ô¾0õ%ë
  2827. +k7§¬!73Óç�jÓÌj+_oò‚„T ЀÅ*¢Ök®$Á˜ HU&Ix@%I“™*Nb„ã?ãÈ’P^Jà˜‰‰ÇrÏ8éx2_ÚkÚ‘ÐÜ¿“‚_t÷¼öh-çÂÈæÝ¡C
  2828. +Í8w…/Ûá”jé™=cžôJ ]é¡xq£ Âöç‰â6rë³]^*ýdÖPáp±Ñ’Sá2ZJjÏßÒÄ‹«œ}‘2[ùùJF—ñoYcŠ‡¾Å¡‚•ÔPÈDÈ ­9B�_¾K~Ç“÷èÚP¡¢û=ÇN~ÏÂð´¡ÏŠ[X#©@*X °"«,Ä„Á8K�•%Èÿd&W¬–’ƒŸ° Ër‘Âéµ³&6I·Œôé ïwo+†ô˜ìܺMžR­tòØŠÅBç::¤dëÄÎ t×+³ã…aTÅx6Ÿ2‰ÀKiò‘"ë\xåiŒr8áøŠ#Ð|pʾáÆâ$T 0dÖ2Ñ Ëró­ÓÖZ]Ö0t¶+¼ýFg‹"ë�3…S®G{O¹üòœ&¨ŠÁ\É}C”W…çÌo ÷Öºñ €Š\« VB ÄH•—ƒ
  2829. +R`%0 @Ht
  2830. +ÂAq0P ’(S€T
  2831. +d�r(�G �€w”Hš�2ÆR”}-E{vXÀ=Ç)˜…SúçÏT‹…Ýe×!8™?Ì(}˜Uù9î.c†ÌáIû�2ϲJ©m¡,¾XãI>V‡)[èÜÂ%I%OÏô\¼ñ –_ÒÇY+^ѩ¬p.k;§ |J¥—ÌýA%—_Xž<ÉäO#Eòc…Ó×ÕHú_]ðñ[÷f\g8CëïoSTÖ«$V´/k‚�X‚‡BC$CA"8à?Q¢fm€Å”¤¥K“ ÇEHG]&Q–’«™–Yá…!B’HA2“ 1xBYÇËL,p—(+W»Vç´–PC5O׺Æ�ü—l]zõD´t)OÆ«IQ�è·< ;i~Ä4 ¶@óºÃ�¯°éŽB1'|iAŽH¦ÁB˽ùF'M9^4bÚ÷éüˆvø�˜0ƒû¯4ÊEóÖ �?aŒ•Ò0áp~ÕöÒÊj&%ŠI‰ hP¦U�ÍÌüt‰²÷ûÐ,PMÔ…@@‚ "#’|„0DR’ï~Q·@ºå2’hNúôf”P©ÏÇí/pêõ�°t©œj\ñxîšM=rq!ÐHO‹hy¸Âù.ÒÒEùkË�IÁ°¶8?�î÷‹„±â‰íЬ£qð¶ë>,(ÛŒÈÂ<ÕYá�Ðjb�Øœ7 @ØÐFJì}»ÇãôW–RKˆçÍÆ&róÍL¥u‡U¥/ÃUCŽgsC8ÅG÷DžfoLºOÜ,Úþ¡ñ•«Kv–äI*ƒÿJ5ñ%Z¼’Å ðå0F-aRìzneŽñ�(<šmÀŸGªioLtyÈÃç•hâüðb lí&¸�eé`ï¹0«ôÍ9#·[>QNOÝûKì8Wüa×Y·óù·/ÅŽ4¢yLÖ®ý9–´/W�Ewx{ÚÈžJ è\Ø¡$´h™}öÆz+´4a,¨ZIIhÌ쬼£‘ú™œm&õÃÊÒ3 EÞÕ§Ô�@ƒ�*zK‹ ±éî4K/w�OÌç¼»sN+pþØ;3Æ…Fùü¼d~x4Wéà UŠB À)d€}p—4Œ�~DÌü´Ž‡?{‰Ù=JiËÞSŽ‹Z`�r¡- éøëß(Ìð§)$ñ1ëÌç4èõAÍ!ˆœÝQ@®ìèÎÕ—Æ>'ê8<`6i<S³ù8ËÉŠ7F³mã¬xïÌç
  2832. +U|+V_‹üUËcÖ2n…cÖ¼æQ‡‹dåŠKŠ¦â¬üFÖŒŠyKm8s—3Æ\.¸h_~ªxàñ%âõ´P|¢al 翾L Å:yŒ|o×JR?N�.}D£?sÓÔ1(ìT{·¨2è팟³» �~ ÊŒ¦¤ R€ X6d€€(Ò@€
  2833. +4&%¨"QÉ!U�0ü.uÖšrQØZÜK�
  2834. +TÂÒ�åèüùiÿ)ÓÌ"ï~Q
  2835. +à c3-LôYä7ÅžuÂïxƸtGx™Â< éÞ<’x=]¯àÎ¥¼])žšñüF%¦á7æ2·[>_ÃTðUôðW¹æìþ£„R©N4Qò…“ Þ£‡j,ÛH`f¤]ÐLÓŠ˜Ôã"á”Ä£?8ä´—àþgÝöÕI’9$’¡I$“¬.︹^åú/¨aùÅ#$[bKvM©… ˜®ÜÝ!Æ’kí’8~Ý+„[k½}`zêví…éŒp{OIÓòQÅ})FÏ¿…š…�€~-ò‡)ùa:Mûà9©ÖüxâkgóqHÈ]Œû�Ïó¸ü±×7Y'Täî{È¢9̤èe´º7ñB¢¼Ò©xàqçø°!(IÉy‘а“cÓÜ)ù©›LB ,¦f‡iRxp!SKº«¢ªvUžµ€)N\}c“ù-ÃǽÕa_¯�ÚÐÃ
  2836. +„Ÿdv§qÅÈráo1úV}±FÎ*M¹+{yÇ`htà¨) ǺûÇ‚#øØØž$%ÓçZËG´{áF@»F÷ž3Ƴ²ð‰N~vv¯ŸhɘØ0*TŠ¯A@°]hâÊpyXŸ0«†+3b<ˤH奚‰Ê&hòV¢æ ²ÅJ[ŒÇ«N<ÞcÑî‡_Ø/l¢QŸƒ4%0(…ÇåøŠÃkÕ»Òo{‰§ª"E�îŠ$»ã8¾ýlc÷¹7ž;»GÐyìc©oöxÉõO0K‰*A&ÀT‰!R¹{9©+šH5&¿·mwXÎg:f!ÊäǺJ¶‹‡9¡ZKH¨\2ôJÚÈmoy¹ÉSèoã*uõËìé7º@TyÕ$±É~¹‡^Îý²­åSýì•gv|þ� %rL€C˜ç+i´õׇ¿LLÔŸc¯l ’”~äòŒC:]ù,Œs1šèC<7ÁÌ©}­Ž¼¬ ÔRFe.jË)³´U{îØZq‰o752Þ*_þ¨zÞ‘TÒ5’Šþ+@.¯¦\vÜ>šÛ3'�ƒÏŠ¿‘ZÕW·}³Å6wª�$¬
  2837. +nT,J+§^ c;lå£hEÕ¶¦«ÚO¼bþ~R:‹\g‹I_¤jž
  2838. +¾šcÓÜ9Q9÷]¼�) "¤èAGzóå§#¢‚@B�JP-”_ø»¾âv½Œpr7ëGœpvçfùŠ!µvŽ/Îìö‹½�óÌy¿…ë3Y:ô‡yé“Ø«G{¶µrÍp…9ûç×bÓåtµ€þ^‹ÆH�lžy`/2-Ë¡¤gf\ªªö´ ÑÊ…iÍÓ¸ÚG†‹*´Ûƒ·V'yÆ}ßcÁÑšY‘SßB¾Éõ
  2839. +ô/b(j @ Èÿ.omfz}Dê÷šV¹¦±ÆÀw á(üz[‡…6ÿK£fŒ…(5N¨é.,9/ªa” ü!y,’–ŒÎá/�óHá-| jLã ºÏ(ì2ý]0¢Æ%þµ³À ËrË;Õ²’Ù‰=0ÀñZÑj³Û—qI?ƒò$uW±—�cÉÔÙtáXJT›³'SjÊ‚<®Ù–�Øá¤Tó;¢+Z*=—µ="C×Ͷ„Øô÷eÚ�$íÂÑîƒ_ØáB*~tÍÓìfûŒ-û¿
  2840. +B ó  @€�r9ú�@ûˆ±¬cƒcG¥ÅPÇ?�1ø_öNm*‰ó˜Íj°çüj§žåâ�Û Ç±çŠN7©=—óŽëêðÀØÐ'|r\`—®'¡Æ5/ËÕèÐå»Óci©„Øô÷üCýë|{FHz=PóOåJ:%Zõ G Í,¼f‘8;µ'”쑱Ð?ŠF}ß¹žÓºšm™‡2ÒSŸ;—gÈ™©>Ç^ØFaRSº0™«2ÔóنȆ5~jêè¥ZØ4qz=
  2841. +6-·5óÊ §9ŽÚG¤"cv|à•Â£ìÚ¯µåÒ‘PÒZnµâN<—’ûh d�µl;G¶Ž;äs!£L´›Ï‹¬f;üøÑŸwßíEµÛ½âFãÙéÛ‘™¥(“ìoHÚšÏkGU +v:ŒVàW9uxÄU·ëXRÔ­šAGc¤×5tY4]×¢Cñ)çya ¿®}eꞪ$®THKª®ñ²ˆ¼í=#;c ÃO:í\°Š-%Ž‹H»”™cØ`Ö)„R˜yÎ8\¬’ÞgYƒoßèá)¡œÕä“/ŠJQ1}§4nn�»¾ã²­¥•Rxÿ*I5Õ]•BrQGô©ù§qˆÛÂþjy/ă�¥„W›Ìt:-zÏ["œž"ÇOZrQI¼øÂtÒª…Qå;a:ciÙÿ’xôYe‚M¦Ñ p4Ž·¥ZT�MÒ_˜.?ËQÌîhg ÑÓNý"bž�,ÑÐêºC ¾•SQê=žê5ý�ZNˆ»üá T%(”F¤ÒPçs†ñs®´Ó’‹ÛYŽ¿%çäÅOÝ;ŒòÿÓ§Š22m1ºÑ(‘S÷Nã¼ã/&3tûü«^H'ô€¢kî 3jà=–%H-°€*b�ý4$hþ {¶P›žž Ë04�5]+›@
  2842. +eZ¥•`Ò Ep ¡|Å°>B3O¦V€*R}¿°4Ê �Ó§v¯ô´Ü‹´1)ýûŠ ·úN2ò`‰Lg¤ ÅUÁxÑ9ËÈ�ÿÄ&!1AQaqð�‘¡±ÑáñÁÿÚ?`Ìžé4²�4/�OܼW«9$Ê r‡¾jà+
  2843. +‹ìÐ=©ÂI7šêJóu±sŠ úh�Š 8ÁD€^a,)`@„É�ÅRàßF!˜ìPBè ©]B8Q˜B€+2CÑ=.A„‰P1 I¥#’ÿ>Ò‚’Úû„X‚Kš™Ä>Áä8 »2ËQ¿ÆÓ"†¢EÂ,´€Ä.¥ µ]ŧøÔg/À9A"Oa, JÛR¡ê€I½§¬í„JHq}rðîL8FàÄ¡µWãGl3qMæÉmgƪ®–u!a¡ÏRe P†éÏŽÑÂ*å,'oØP¥‡`_ø HPÚ2¦!Y 0¾ƒƒE]V%D�2¹TÕØ)‚«¡W8ÎF*— ²À!ŒÁÑ–ÔLFÂy g:�AÔÔ ‹´Àg�- j¼‚Šä pÊX F…�D0U ”š€Æ‘"Jrê
  2844. + ’ZR7ì¶!RàĪA@ë‚$ûY
  2845. +Ó�Üš2 Xù *ÿ`zKAöÄXeii¸èœ`ð»¤Ó�r5Â?Ø|›­=xÇm´µÁj™àÀãiDcJš™’¸¢Ruî/À"Š­¤/Ó.‹©òAÊ=-sœ€‡Ö…àÖA¾u%lx!*!+ô pœ  oñ¤|•Q!dåSìôÇi$`D.Ä‚ Ž<ÐaLr˜C$á��sÅU/[DH�9- N§c1ð„O> `Â�¢](jã ×
  2846. +E\ûâa¸À @VÊC«SÂКÁÜÅ>Ë A‰:ÈhNPˆP&ÿ'89AµàŽ‚©-qTðÐ3DF‡À8"½³�ð;ÿÖ6—|´ãèÀ �@ t«2D24�úˆµ$ÄMŽ õÜîÁ²á»¡�°5bKˆ/2rTt£ÏÎBA)CjTd¸I¡6H$åÜ•‹Paò�($c @: �€™!0A�dSB–+!ß,D–”Œ8Ø¢�/lž œ#«ÃBÙYgÙÇU
  2847. +½ÓF ÂiöÑt\º¢£Kþ…@* $D´ š 3HÈhØhÒI°½jr@7©@‹žLØž�¡@ƉÁ Ë�_è¿A¤b *�³B{†›)c�¤ÅMàÓЛo!o¶£ur`bÇ�Ú  ŸŠŽû:ìOa1éãmÙyÿ ‹X›‹–†']*}’þC‘Á…´²îmV’¥_Øßš:š1ëGTÄålHŸÅ„jIc š�#äŒfQE†ÁX„ÂP68«’y3†‚ÿXˆ bÆkßàNa½ƒ¡;6Q€ 3Å­ÈტGZìÎöXDЮ´4„ã¢ö ÂÈÚXvºý%[_Á‘�ƒ•~•Ri±'ì„r :‹Üwßà(ˆ�T1XDÛ�IÔh�J`°"Ä x¸#Ú…ÎÇQý—Ï(vÀROª…¡èb%Ç…rÒ¤_¤~hrD�¾*5=ÁŒÚu–(@¾“ô/E»K ÙQ¡¶N²C„*F À�ÝV:›ÆP9Å‚‚8@~ïð„†"O ÑU–@`�­ƒwXÅ :¤¶ÀX/ Pi"‘²†ŠÆÉ®¢š€"ýEþ‘ Lá8BÍ["‰LQåWM€0úY�*Á¡à R* ìžS¸û—6
  2848. +l‘A}K€R@àÂõ¼–†ÈÏ^ w�An+®* Ä\ih,P†ÚKZªØ¢Ál+éo C($'h£²Ì]z,+{“d)ÄR–ÉÉ„ƒIöù�—OÖ-ŸB\™ƒ¤Ëàw‚°"M¨¾Áé4.˜«Z¡Dho…y}x^I­RŠgúék(w×Åi%�\ŒU䱤€ .d$ !X
  2849. +5¯¼C…^R@Ó‚zY4)l'¹oxA`J÷ˆ,QƒùRžR™o¤jÀ>E�Ÿç+chaÉ5"în ™»&€
  2850. +€aè}éXVJW„‚(‰n¬jE ÈM¨:eJxpõ\PÕý«D=c¿%tR~åuEI@Åoœ¼‰ J¹°RÞqÕAL‘¼Dx@†+O¡1&J†1å? POX$KÐC:†0†
  2851. + JZ™ˆp³Ï ¯PQ@Y¡�¢Ëªrh`;ËAG+ÀŸ2¤~  4p…’PCêg6—�j3ƒ �:M@ €¯¹ÿÀ¨�L˜•ˆd�êÉÀK.ÄÔ¦ƒû`/‚¡fˆ6Ï?àè¬þš#  ·ÀXô]º1=$‚y¢è›¥…X…åø˜žÙó–á•Ô5iâ(‹;h¨éLÙTª¡®Zó‚\’pµ&ëÈ°SÓ[v¾tòI‰ªÙ­î²B Znþ6�A78Ýãû½Jø
  2852. +8_s°�"€dN…*,æA«
  2853. +ªÿ. †ÒWA©V¤F%H×øc’#bÁP$RaA�J^ ­À‡IPËÉ)XNX?È �™3,°Áæ8¬0ÛhÏI;’UŒÑ›Úñþ¢Z&¿Âj§‹eÒÄ#�ï_*„t£Ø›û¬ ),Sô‹€^¢@À&‚ÐÉ�y¦Hw0b=ÔÙXBBãâ9+±C'E¸’dÞðëè!X‹`{^YÕIÇ'ã-ûàÛ‰ûDìÚ|wÍÖŒÐ;íé³0&¦xlQlB…sÚˆ³$„ {žŠÄÑ‚AS#€“öGÄLL3)„ŠÀm`DzÈd¿HIÜFƒ2û8+�M¬¹ù•€’”6b?ܸɖ`QÕ+pJnG£‰b@§_‰P
  2854. +þŒ?ܧ%Ð0‡Q·ÙH zNÏñjKI¢­Y'¦ ‚µkYjNÔ@,žµ¢H5�z‚Qãõ1ÖSÕ¼ã'Š/ì#!1âÊÆËUO/1~8„IýÖ¨}²ôM àrŽ®NDõ?²@�‰gR/Urj`!£œN·ø7#¨( бBBLÀŽ´¸ã@·¦0ée€–CB5iØ›$AoM aö/*0F:°¸JF|à}ƒÙŠ^ÔÖ¤”á�5ÐÌUAÌEø�v‡f`
  2855. +…¦`™Nsi„d[OŠ°äX).öM½�Gv\w,,@i·©¥º9L ‚ŒQ0âeضP–…‹bAd´ÔìZ—À–DÓ –´ƒN®Jj@fa¯´áuŒ’ôÉl¨ Œ]µÊ´—F�×\ÑjÈ#ºèOPéî<Ð>€É¯=æÖëä ‰•]b$6"äM(¤к—‰jm(YªEC0Yf b&àü€TöH3ÖC)H¨3AbAUŽV`
  2856. +ƒÀ; ‚)ú_h*,6N¾eFÇÍt]éNÝó®„ =�T(Ö‚Áöø3±8Õ7×8 DP×JL÷˜ Ô4I+Õ #ŒÍ@q½“�9¾ÊBe$€;¦{ $à‰:Ø™"$ŒŒ/D8¸�ƒssq¶Iš’Úz^ ‰×ŒV„(`píhQ§ìÆg΄½Éøáø¸dvjbUIZ!ýÍV ¥ B—`„#ŽØ.wÖ!ƒ²²ã¾ Æ°aÙMŒƒ@”4š¹8‚æã‘eBV²�e
  2857. +I ‡Ï‹Ðè¿TmÁAåa��ßÈÈH~Ê'3- ðZÑL´®òGyXÈóvCÔ ¦ídÄpÃçq¦íYkH„_b!8(l�ãñpž¡ÏAK´À•�jïŽ>h%@
  2858. +ëªú@¶L%éÄr&ÓÁ
  2859. +i‡q�}Ú.€ðf9î ì ˆÈcüj”y ’@ëögIp6ð—îªäàŽ„þ"X&
  2860. +“zH�5”«‚ÁÞ% Ä-
  2861. +XÁXˆ� Ö(pXanø+­) aÂJÐB JšÃPs0`Xk©A ZŒ
  2862. +›‡ú JúäIv&¾œ šKÀViðõZ„Ìܦ³éјB©©¿HNº¨á•p?‹Rp: ÙÚßµ‰¥ƒNßu¢biCêJ€ØääÀ¥A�®C²PÁ „)JŠe`XŽ;/eI$ô„ŸJž ¬Æ+Ý"‘—Ž
  2863. +©RðÎy=+XFlf^® y¸Þ¤œà‘„àÛŸ
  2864. +¤E‚˜¬Ò#X³"oIrú€Œ APåñCo
  2865. +�¯%µ! ´!V=Ad
  2866. +ZëX¿¤R³�R¤e«¼5ƒÜ‚Læ:u- ¯wg'/R2 �®Vp|¨êœDCá¶ä¢Lô&Ã(èIFP'x‰ ˆ �ÙÜ
  2867. +�)Ã{ç2®  gó]äðÎÊà}·Z›h¸T E¡ÂÀ±xew’jn^Q;Bb‚냨 èoÙA�ž¸Z—Êø!"å—2¿ ¢µ¿IËÅ 3©¡Éy"–‚²Å°„8t­˜hK ×<× 6;À Wä„ çè%¾—À®$hOËEÕÞÌ ÆÌô\Œ s‘qhh‡§ºdÊ?µxŠhúàØÐËeò$|1MQÕÕÈÀF·Û¢ÉCÚ=7ÕX• ÌX´*I£˜µô²"CA CÖ÷«u&Åiûí@öNå´LEüsÒ›HRAÖlTH0 /UL®Nò]°J¹ Pb øµ.¤‚¥àÊ$\og–`!b=ÝÚš·�
  2868. +Ùè`ð‚ÿ- ¨€¦1ÅЈ!s°½‚´ŸPž´]B²Yá kAØ<­ˆbDK±n&ÄQ:úÉ�ªËbmSá‹¢Å5(ád c¬K@öåþŠ@1õØ Hƒ‘ÀgjT2`^A¨ÞhmF÷9Ìx–y”IH­aÒåJÉ!ÆmÚ®ä&7Ãè0‡ _!æb@$;7®ðö¶¾‚þOµý'™Icu Æ€’Ý*ç¦ œDˆ"¬B^ð ÖJ‚›FWÍØö¿Oð‘Ôitȵq6:pG6Ð7Rø!
  2869. +]�CÕ+? Aa[V_,@”(-p´"€À½ÐJÁ Ÿe-‰¤@,«{CR…­½Äáë_¤
  2870. +†ØÍ÷ôPGJ Õ© Dµ^µÂò(úD‘çïÍ–àé¼·¥ph9›ô5{õ¸I3Å®5g_õ
  2871. +0öÑYŒVg�‹\SÊ1N/ÌRÎÙ™Ï�ÑväùËå=m(+·©9Àé®æ©ÙÁ%Ó¿ÈLVèÜ”Ä)ÙL7fÞl {Ÿž« -™'_ ¯¶q"BëöRzPX^k@ýñK¸(Y@|v k?":e`qò„”" 3–5‚Zþ�P‚ÃhÅ £z ³ª™Kg s3;ëS+ öU|ð]Ý œ ‘h-•Òó³ñÍ—€�ÏmÖðsÍ*‰S’^üuàFäBpVàôŸ¥ðOvßYÄÅ+ UßEÿL.� fÚ. PY�È)��þE�4¡i•³Y´$Z —ö –0÷ë^ãœk0`°E‚ \èJÖÇ=o{uSS¹ÊY°`!�¤‡b@`’<)B°U£<®Á@e‡pÈœV@@6PöNÖU¥¥”0‡‡ At!�.R`f“9'ÏX„Ä°oÀèªOB$nå>5-v!…Ã�lÄ´€x*:$ê‘´"KûXùì
  2872. +û³s]‰ÒHχÝ4)A¼2 nú\°¾ʨ
  2873. +0�^zÝBS è§^ÝxMê;ùMG,®ç{Ѩ‡ õvàX#ÀfXÔ® O|æÛ Od¨cð]T•QÛ‡íº/ÀTXiËAD€óSÌ€Ó=<±!Ë‹~]pªCNÙõBµ$Uc¨-g.‰C|KYª£‰Úd$»³¹_ ¦§"p�9Pˆ«ßñÕc݈´0®`‚a.HÜ—��¯‡tA×o›ð•z@/òc¯• —’hiC^¾´AÇ5šl‰07ÇšÐsÞ^a9 ltø&c”ù›ÿP' GôñMÕÅ/$æ½Tˆv#®ÞY¥p}ß4=–njóä 7»5P�F z“@¹U?˜«�ˆXR@~ëB¥«lOÈ^K(¥›\kdÑöyáCÇ+„ËIêòN«V‹B‡ž’êà£%
  2874. +í6TŒÎkåÚ`)âkìj½‘…}æÒª tÝu ¬�)Õ‡È ÆåTfí�,sˆìB,Æç¿f‡—ö¼ÁÅ£×y[6õæ(¶#hM˜jkEü M¤kEý‡/Ñ\±aluï-X$_ã™\ 鲪µrì_�ÂàûðôX¤ø 5u©97sªÆNî=XÄ;Yªß$ö1w(yBÍ�lW„Vì%@|xа2�”:AŠË¢¯o=—4ŠÁ™õÚ^¦d€1ÝK�ŒÊ 9I²¢"î5E“ä�6Ã;À¬Éf3.Ê26 Yã„v|¢­±Ã7¤B%ãڀ꺾xh‡kÄ3)iPd£#,à„él6\CåÖäîÔÚø=R‹¶N�#Âx9ÀÄ‚ ñ:¡3 ¨l¿eSâ`.“Á£¢2 >ìŠ4E‰dÞP�ït'
  2875. +váŽÉ²²]0>�g�+ÿÙ
  2876. \ Dosya sonunda yenisatır yok.
  2877. diff -Nuar flatpak-1.0.0.orig/bubblewrap/bwrap.xml flatpak-1.0.0/bubblewrap/bwrap.xml
  2878. --- flatpak-1.0.0.orig/bubblewrap/bwrap.xml 1970-01-01 02:00:00.000000000 +0200
  2879. +++ flatpak-1.0.0/bubblewrap/bwrap.xml 2018-02-03 21:26:06.273233339 +0300
  2880. @@ -0,0 +1,320 @@
  2881. +<?xml version="1.0"?>
  2882. +<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
  2883. + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  2884. +]>
  2885. +<refentry id="bwrap">
  2886. +
  2887. +<refentryinfo>
  2888. + <title>bwrap</title>
  2889. + <productname>Project Atomic</productname>
  2890. + <authorgroup>
  2891. + <author>
  2892. + <contrib>Developer</contrib>
  2893. + <firstname>Alexander</firstname>
  2894. + <surname>Larsson</surname>
  2895. + </author>
  2896. + <author>
  2897. + <contrib>Developer</contrib>
  2898. + <firstname>Colin</firstname>
  2899. + <surname>Walters</surname>
  2900. + </author>
  2901. + </authorgroup>
  2902. +</refentryinfo>
  2903. +
  2904. +<refmeta>
  2905. + <refentrytitle>bwrap</refentrytitle>
  2906. + <manvolnum>1</manvolnum>
  2907. + <refmiscinfo class="manual">User Commands</refmiscinfo>
  2908. +</refmeta>
  2909. +
  2910. +<refnamediv>
  2911. + <refname>bwrap</refname>
  2912. + <refpurpose>container setup utility</refpurpose>
  2913. +</refnamediv>
  2914. +
  2915. +<refsynopsisdiv>
  2916. +<cmdsynopsis>
  2917. +<command>bwrap</command>
  2918. +<arg choice="opt" rep="repeat"><replaceable>OPTION</replaceable></arg>
  2919. +<arg choice="opt"><replaceable>COMMAND</replaceable></arg>
  2920. +</cmdsynopsis>
  2921. +</refsynopsisdiv>
  2922. +
  2923. +<refsect1><title>Description</title>
  2924. +<para>
  2925. + <command>bwrap</command> is a privileged helper for container setup. You
  2926. + are unlikely to use it directly from the commandline, although that is possible.
  2927. +</para>
  2928. +<para>
  2929. + It works by creating a new, completely empty, filesystem namespace where the root
  2930. + is on a tmpfs that is invisible from the host, and which will be automatically
  2931. + cleaned up when the last process exists. You can then use commandline options to
  2932. + construct the root filesystem and process environment for the command to run in
  2933. + the namespace.
  2934. +</para>
  2935. +<para>
  2936. + By default, <command>bwrap</command> creates a new mount namespace for the sandbox.
  2937. + Optionally it also sets up new user, ipc, pid, network and uts namespaces (but note the
  2938. + user namespace is required if bwrap is not installed setuid root).
  2939. + The application in the sandbox can be made to run with a different UID and GID.
  2940. +</para>
  2941. +<para>
  2942. + If needed (e.g. when using a PID namespace) <command>bwrap</command>
  2943. + is running a minimal pid 1 process in the sandbox that is
  2944. + responsible for reaping zombies. It also detects when the initial
  2945. + application process (pid 2) dies and reports its exit status back to
  2946. + the original spawner. The pid 1 process exits to clean up the
  2947. + sandbox when there are no other processes in the sandbox left.
  2948. +</para>
  2949. +</refsect1>
  2950. +
  2951. +<refsect1><title>Options</title>
  2952. + <para>
  2953. + When options are used multiple times, the last option wins, unless otherwise
  2954. + specified.
  2955. + </para>
  2956. + <para>General options:</para>
  2957. + <variablelist>
  2958. + <varlistentry>
  2959. + <term><option>--help</option></term>
  2960. + <listitem><para>Print help and exit</para></listitem>
  2961. + </varlistentry>
  2962. + <varlistentry>
  2963. + <term><option>--version</option></term>
  2964. + <listitem><para>Print version</para></listitem>
  2965. + </varlistentry>
  2966. + <varlistentry>
  2967. + <term><option>--args <arg choice="plain">FD</arg></option></term>
  2968. + <listitem><para>
  2969. + Parse nul-separated arguments from the given file descriptor.
  2970. + This option can be used multiple times to parse options from
  2971. + multiple sources.
  2972. + </para></listitem>
  2973. + </varlistentry>
  2974. + </variablelist>
  2975. + <para>Options related to kernel namespaces:</para>
  2976. + <variablelist>
  2977. + <varlistentry>
  2978. + <term><option>--unshare-user</option></term>
  2979. + <listitem><para>Create a new user namespace</para></listitem>
  2980. + </varlistentry>
  2981. + <varlistentry>
  2982. + <term><option>--unshare-user-try</option></term>
  2983. + <listitem><para>Create a new user namespace if possible else skip it</para></listitem>
  2984. + </varlistentry>
  2985. + <varlistentry>
  2986. + <term><option>--unshare-ipc</option></term>
  2987. + <listitem><para>Create a new ipc namespace</para></listitem>
  2988. + </varlistentry>
  2989. + <varlistentry>
  2990. + <term><option>--unshare-pid</option></term>
  2991. + <listitem><para>Create a new pid namespace</para></listitem>
  2992. + </varlistentry>
  2993. + <varlistentry>
  2994. + <term><option>--unshare-net</option></term>
  2995. + <listitem><para>Create a new network namespace</para></listitem>
  2996. + </varlistentry>
  2997. + <varlistentry>
  2998. + <term><option>--unshare-uts</option></term>
  2999. + <listitem><para>Create a new uts namespace</para></listitem>
  3000. + </varlistentry>
  3001. + <varlistentry>
  3002. + <term><option>--unshare-cgroup</option></term>
  3003. + <listitem><para>Create a new cgroup namespace</para></listitem>
  3004. + </varlistentry>
  3005. + <varlistentry>
  3006. + <term><option>--unshare-cgroup-try</option></term>
  3007. + <listitem><para>Create a new cgroup namespace if possible else skip it</para></listitem>
  3008. + </varlistentry>
  3009. + <varlistentry>
  3010. + <term><option>--unshare-all</option></term>
  3011. + <listitem><para>Unshare all possible namespaces. Currently equivalent with: <option>--unshare-user-try</option> <option>--unshare-ipc</option> <option>--unshare-pid</option> <option>--unshare-net</option> <option>--unshare-uts</option> <option>--unshare-cgroup-try</option></para></listitem>
  3012. + </varlistentry>
  3013. + <varlistentry>
  3014. + <term><option>--uid <arg choice="plain">UID</arg></option></term>
  3015. + <listitem><para>Use a custom user id in the sandbox (requires <option>--unshare-user</option>)</para></listitem>
  3016. + </varlistentry>
  3017. + <varlistentry>
  3018. + <term><option>--gid <arg choice="plain">GID</arg></option></term>
  3019. + <listitem><para>Use a custom group id in the sandbox (requires <option>--unshare-user</option>)</para></listitem>
  3020. + </varlistentry>
  3021. + <varlistentry>
  3022. + <term><option>--hostname <arg choice="plain">HOSTNAME</arg></option></term>
  3023. + <listitem><para>Use a custom hostname in the sandbox (requires <option>--unshare-uts</option>)</para></listitem>
  3024. + </varlistentry>
  3025. + </variablelist>
  3026. + <para>Options about environment setup:</para>
  3027. + <variablelist>
  3028. + <varlistentry>
  3029. + <term><option>--chdir <arg choice="plain">DIR</arg></option></term>
  3030. + <listitem><para>Change directory to <arg choice="plain">DIR</arg></para></listitem>
  3031. + </varlistentry>
  3032. + <varlistentry>
  3033. + <term><option>--setenv <arg choice="plain">VAR</arg> <arg choice="plain">VALUE</arg></option></term>
  3034. + <listitem><para>Set an environment variable</para></listitem>
  3035. + </varlistentry>
  3036. + <varlistentry>
  3037. + <term><option>--unsetenv <arg choice="plain">VAR</arg></option></term>
  3038. + <listitem><para>Unset an environment variable</para></listitem>
  3039. + </varlistentry>
  3040. + </variablelist>
  3041. + <para>Options for monitoring the sandbox from the outside:</para>
  3042. + <variablelist>
  3043. + <varlistentry>
  3044. + <term><option>--lock-file <arg choice="plain">DEST</arg></option></term>
  3045. + <listitem><para>
  3046. + Take a lock on <arg choice="plain">DEST</arg> while the sandbox is running.
  3047. + This option can be used multiple times to take locks on multiple files.
  3048. + </para></listitem>
  3049. + </varlistentry>
  3050. + <varlistentry>
  3051. + <term><option>--sync-fd <arg choice="plain">FD</arg></option></term>
  3052. + <listitem><para>Keep this file descriptor open while the sandbox is running</para></listitem>
  3053. + </varlistentry>
  3054. + </variablelist>
  3055. + <para>
  3056. + Filesystem related options. These are all operations that modify the filesystem directly, or
  3057. + mounts stuff in the filesystem. These are applied in the order they are given as arguments.
  3058. + Any missing parent directories that are required to create a specified destination are
  3059. + automatically created as needed.
  3060. + </para>
  3061. + <variablelist>
  3062. + <varlistentry>
  3063. + <term><option>--bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
  3064. + <listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> on <arg choice="plain">DEST</arg></para></listitem>
  3065. + </varlistentry>
  3066. + <varlistentry>
  3067. + <term><option>--dev-bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
  3068. + <listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> on <arg choice="plain">DEST</arg>, allowing device access</para></listitem>
  3069. + </varlistentry>
  3070. + <varlistentry>
  3071. + <term><option>--ro-bind <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
  3072. + <listitem><para>Bind mount the host path <arg choice="plain">SRC</arg> readonly on <arg choice="plain">DEST</arg></para></listitem>
  3073. + </varlistentry>
  3074. + <varlistentry>
  3075. + <term><option>--remount-ro <arg choice="plain">DEST</arg></option></term>
  3076. + <listitem><para>Remount the path <arg choice="plain">DEST</arg> as readonly. It works only on the specified mount point, without changing any other mount point under the specified path</para></listitem>
  3077. + </varlistentry>
  3078. + <varlistentry>
  3079. + <term><option>--proc <arg choice="plain">DEST</arg></option></term>
  3080. + <listitem><para>Mount procfs on <arg choice="plain">DEST</arg></para></listitem>
  3081. + </varlistentry>
  3082. + <varlistentry>
  3083. + <term><option>--dev <arg choice="plain">DEST</arg></option></term>
  3084. + <listitem><para>Mount new devtmpfs on <arg choice="plain">DEST</arg></para></listitem>
  3085. + </varlistentry>
  3086. + <varlistentry>
  3087. + <term><option>--tmpfs <arg choice="plain">DEST</arg></option></term>
  3088. + <listitem><para>Mount new tmpfs on <arg choice="plain">DEST</arg></para></listitem>
  3089. + </varlistentry>
  3090. + <varlistentry>
  3091. + <term><option>--mqueue <arg choice="plain">DEST</arg></option></term>
  3092. + <listitem><para>Mount new mqueue on <arg choice="plain">DEST</arg></para></listitem>
  3093. + </varlistentry>
  3094. + <varlistentry>
  3095. + <term><option>--dir <arg choice="plain">DEST</arg></option></term>
  3096. + <listitem><para>Create a directory at <arg choice="plain">DEST</arg></para></listitem>
  3097. + </varlistentry>
  3098. + <varlistentry>
  3099. + <term><option>--file <arg choice="plain">FD</arg> <arg choice="plain">DEST</arg></option></term>
  3100. + <listitem><para>Copy from the file descriptor <arg choice="plain">FD</arg> to <arg choice="plain">DEST</arg></para></listitem>
  3101. + </varlistentry>
  3102. + <varlistentry>
  3103. + <term><option>--bind-data <arg choice="plain">FD</arg> <arg choice="plain">DEST</arg></option></term>
  3104. + <listitem><para>Copy from the file descriptor <arg choice="plain">FD</arg> to a file which is bind-mounted on <arg choice="plain">DEST</arg></para></listitem>
  3105. + </varlistentry>
  3106. + <varlistentry>
  3107. + <term><option>--ro-bind-data <arg choice="plain">FD</arg> <arg choice="plain">DEST</arg></option></term>
  3108. + <listitem><para>Copy from the file descriptor <arg choice="plain">FD</arg> to a file which is bind-mounted readonly on <arg choice="plain">DEST</arg></para></listitem>
  3109. + </varlistentry>
  3110. + <varlistentry>
  3111. + <term><option>--symlink <arg choice="plain">SRC</arg> <arg choice="plain">DEST</arg></option></term>
  3112. + <listitem><para>Create a symlink at <arg choice="plain">DEST</arg> with target <arg choice="plain">SRC</arg></para></listitem>
  3113. + </varlistentry>
  3114. + </variablelist>
  3115. + <para>Lockdown options:</para>
  3116. + <variablelist>
  3117. + <varlistentry>
  3118. + <term><option>--seccomp <arg choice="plain">FD</arg></option></term>
  3119. + <listitem><para>
  3120. + Load and use seccomp rules from <arg choice="plain">FD</arg>.
  3121. + The rules need to be in the form of a compiled eBPF program,
  3122. + as generated by seccomp_export_bpf.
  3123. + </para></listitem>
  3124. + </varlistentry>
  3125. + <varlistentry>
  3126. + <term><option>--exec-label <arg choice="plain">LABEL</arg></option></term>
  3127. + <listitem><para>
  3128. + Exec Label from the sandbox. On an SELinux system you can specify the SELinux
  3129. + context for the sandbox process(s).
  3130. + </para></listitem>
  3131. + </varlistentry>
  3132. + <varlistentry>
  3133. + <term><option>--file-label <arg choice="plain">LABEL</arg></option></term>
  3134. + <listitem><para>
  3135. + File label for temporary sandbox content. On an SELinux system you can specify
  3136. + the SELinux context for the sandbox content.
  3137. + </para></listitem>
  3138. + </varlistentry>
  3139. + <varlistentry>
  3140. + <term><option>--block-fd <arg choice="plain">FD</arg></option></term>
  3141. + <listitem><para>
  3142. + Block the sandbox on reading from FD until some data is available.
  3143. + </para></listitem>
  3144. + </varlistentry>
  3145. + <varlistentry>
  3146. + <term><option>--info-fd <arg choice="plain">FD</arg></option></term>
  3147. + <listitem><para>
  3148. + Write information in JSON format about the sandbox to FD.
  3149. + </para></listitem>
  3150. + </varlistentry>
  3151. + <varlistentry>
  3152. + <term><option>--new-session</option></term>
  3153. + <listitem><para>
  3154. + Create a new terminal session for the sandbox (calls setsid()). This
  3155. + disconnects the sandbox from the controlling terminal which means
  3156. + the sandbox can't for instance inject input into the terminal.
  3157. + </para><para>
  3158. + Note: In a general sandbox, if you don't use --new-session, it is
  3159. + recommended to use seccomp to disallow the TIOCSTI ioctl, otherwise
  3160. + the application can feed keyboard input to the terminal.
  3161. + </para></listitem>
  3162. + </varlistentry>
  3163. + <varlistentry>
  3164. + <term><option>--die-with-parent</option></term>
  3165. + <listitem><para>
  3166. + Ensures child process (COMMAND) dies when bwrap's parent dies. Kills (SIGKILL)
  3167. + all bwrap sandbox processes in sequence from parent to child
  3168. + including COMMAND process when bwrap or bwrap's parent dies.
  3169. + See prctl, PR_SET_PDEATHSIG.
  3170. + </para></listitem>
  3171. + </varlistentry>
  3172. + </variablelist>
  3173. +</refsect1>
  3174. +
  3175. +<refsect1>
  3176. + <title>Environment</title>
  3177. +
  3178. + <variablelist>
  3179. + <varlistentry>
  3180. + <term><envar>HOME</envar></term>
  3181. + <listitem><para>
  3182. + Used as the cwd in the sandbox if <option>--cwd</option> has not been
  3183. + explicitly specified and the current cwd is not present inside the sandbox.
  3184. + The <option>--setenv</option> option can be used to override the value
  3185. + that is used here.
  3186. + </para></listitem>
  3187. + </varlistentry>
  3188. + </variablelist>
  3189. +</refsect1>
  3190. +
  3191. +<refsect1>
  3192. + <title>Exit status</title>
  3193. +
  3194. + <para>
  3195. + The <command>bwrap</command> command returns the exit status of the
  3196. + initial application process (pid 2 in the sandbox).
  3197. + </para>
  3198. +</refsect1>
  3199. +
  3200. +</refentry>
  3201. diff -Nuar flatpak-1.0.0.orig/bubblewrap/ci/redhat-ci.sh flatpak-1.0.0/bubblewrap/ci/redhat-ci.sh
  3202. --- flatpak-1.0.0.orig/bubblewrap/ci/redhat-ci.sh 1970-01-01 02:00:00.000000000 +0200
  3203. +++ flatpak-1.0.0/bubblewrap/ci/redhat-ci.sh 2018-02-03 21:26:06.273233339 +0300
  3204. @@ -0,0 +1,47 @@
  3205. +#!/usr/bin/env bash
  3206. +
  3207. +set -xeuo pipefail
  3208. +
  3209. +distro=$1
  3210. +
  3211. +runcontainer() {
  3212. + docker run --rm --env=container=true --env=BWRAP_SUID=${BWRAP_SUID:-} --env CFLAGS="${CFLAGS:-}" --net=host --privileged -v /usr:/host/usr -v $(pwd):/srv/code -w /srv/code $distro ./ci/redhat-ci.sh $distro
  3213. +}
  3214. +
  3215. +buildinstall_to_host() {
  3216. +
  3217. + yum -y install git autoconf automake libtool make gcc redhat-rpm-config \
  3218. + libcap-devel 'pkgconfig(libselinux)' 'libxslt' 'docbook-style-xsl' \
  3219. + lib{a,ub,t}san /usr/bin/eu-readelf
  3220. +
  3221. + echo testing: $(git describe --tags --always --abbrev=42)
  3222. +
  3223. + env NOCONFIGURE=1 ./autogen.sh
  3224. + ./configure --prefix=/usr --libdir=/usr/lib64
  3225. + make -j 8
  3226. + tmpd=$(mktemp -d)
  3227. + make install DESTDIR=${tmpd}
  3228. + for san in a t ub; do
  3229. + if eu-readelf -d ${tmpd}/usr/bin/bwrap | grep -q "NEEDED.*lib${san}san"; then
  3230. + for x in /usr/lib64/lib${san}san*.so.*; do
  3231. + install -D $x ${tmpd}${x}
  3232. + done
  3233. + fi
  3234. + done
  3235. + rsync -rlv ${tmpd}/usr/ /host/usr/
  3236. + if ${BWRAP_SUID}; then
  3237. + chmod u+s /host/usr/bin/bwrap
  3238. + fi
  3239. + rm ${tmpd} -rf
  3240. +}
  3241. +
  3242. +if test -z "${container:-}"; then
  3243. + ostree admin unlock
  3244. + # Hack until the host tree is updated in rhci
  3245. + rpm -Uvh https://kojipkgs.fedoraproject.org//packages/glibc/2.24/4.fc25/x86_64/{libcrypt-nss,glibc,glibc-common,glibc-all-langpacks}-2.24-4.fc25.x86_64.rpm
  3246. + useradd bwrap-tester
  3247. + runcontainer
  3248. + runuser -u bwrap-tester env ASAN_OPTIONS=detect_leaks=false ./tests/test-run.sh
  3249. +else
  3250. + buildinstall_to_host
  3251. +fi
  3252. diff -Nuar flatpak-1.0.0.orig/bubblewrap/completions/bash/bwrap flatpak-1.0.0/bubblewrap/completions/bash/bwrap
  3253. --- flatpak-1.0.0.orig/bubblewrap/completions/bash/bwrap 1970-01-01 02:00:00.000000000 +0200
  3254. +++ flatpak-1.0.0/bubblewrap/completions/bash/bwrap 2018-02-03 21:26:06.273233339 +0300
  3255. @@ -0,0 +1,60 @@
  3256. +#!/bin/bash
  3257. +#
  3258. +# bash completion file for bubblewrap commands
  3259. +#
  3260. +
  3261. +_bwrap() {
  3262. + local cur prev words cword
  3263. + _init_completion || return
  3264. +
  3265. + local boolean_options="
  3266. + --help
  3267. + --unshare-cgroup
  3268. + --unshare-cgroup-try
  3269. + --unshare-user
  3270. + --unshare-user-try
  3271. + --unshare-ipc
  3272. + --unshare-net
  3273. + --unshare-pid
  3274. + --unshare-uts
  3275. + --version
  3276. + "
  3277. +
  3278. + local options_with_args="
  3279. + $boolean_optons
  3280. + --args
  3281. + --bind
  3282. + --bind-data
  3283. + --block-fd
  3284. + --chdir
  3285. + --dev
  3286. + --dev-bind
  3287. + --dir
  3288. + --exec-label
  3289. + --file
  3290. + --file-label
  3291. + --gid
  3292. + --hostname
  3293. + --info-fd
  3294. + --lock-file
  3295. + --proc
  3296. + --ro-bind
  3297. + --remount-ro
  3298. + --seccomp
  3299. + --setenv
  3300. + --symlink
  3301. + --sync-fd
  3302. + --uid
  3303. + --unsetenv
  3304. + --seccomp
  3305. + --symlink
  3306. + --die-with-parent
  3307. + "
  3308. +
  3309. + if [[ "$cur" == -* ]]; then
  3310. + COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
  3311. + fi
  3312. +
  3313. + return 0
  3314. +}
  3315. +complete -F _bwrap bwrap
  3316. diff -Nuar flatpak-1.0.0.orig/bubblewrap/configure.ac flatpak-1.0.0/bubblewrap/configure.ac
  3317. --- flatpak-1.0.0.orig/bubblewrap/configure.ac 1970-01-01 02:00:00.000000000 +0200
  3318. +++ flatpak-1.0.0/bubblewrap/configure.ac 2018-02-03 21:26:06.273233339 +0300
  3319. @@ -0,0 +1,127 @@
  3320. +AC_PREREQ([2.63])
  3321. +AC_INIT([bubblewrap], [0.1.8], [atomic-devel@projectatomic.io])
  3322. +AC_CONFIG_HEADER([config.h])
  3323. +AC_CONFIG_MACRO_DIR([m4])
  3324. +AC_CONFIG_AUX_DIR([build-aux])
  3325. +
  3326. +AC_USE_SYSTEM_EXTENSIONS
  3327. +
  3328. +AM_INIT_AUTOMAKE([1.11 -Wno-portability foreign no-define tar-ustar no-dist-gzip dist-xz])
  3329. +AM_MAINTAINER_MODE([enable])
  3330. +AM_SILENT_RULES([yes])
  3331. +
  3332. +AC_SYS_LARGEFILE
  3333. +
  3334. +AC_PROG_CC
  3335. +AM_PROG_CC_C_O
  3336. +
  3337. +AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
  3338. +
  3339. +AC_ARG_ENABLE(man,
  3340. + [AS_HELP_STRING([--enable-man],
  3341. + [generate man pages [default=auto]])],,
  3342. + enable_man=maybe)
  3343. +
  3344. +AS_IF([test "$enable_man" != no], [
  3345. + AC_PATH_PROG([XSLTPROC], [xsltproc], [])
  3346. + AS_IF([test -z "$XSLTPROC"], [
  3347. + AS_IF([test "$enable_man" = yes], [
  3348. + AC_MSG_ERROR([xsltproc is required for --enable-man])
  3349. + ])
  3350. + enable_man=no
  3351. + ], [
  3352. + enable_man=yes
  3353. + ])
  3354. +])
  3355. +AM_CONDITIONAL(ENABLE_MAN, test "$enable_man" != no)
  3356. +
  3357. +AC_ARG_WITH([bash-completion-dir],
  3358. + AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
  3359. + [Install the bash auto-completion script in this directory. @<:@default=yes@:>@]),
  3360. + [],
  3361. + [with_bash_completion_dir=yes])
  3362. +
  3363. +if test "x$with_bash_completion_dir" = "xyes"; then
  3364. + PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
  3365. + [BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
  3366. + [BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
  3367. +else
  3368. + BASH_COMPLETION_DIR="$with_bash_completion_dir"
  3369. +fi
  3370. +
  3371. +AC_SUBST([BASH_COMPLETION_DIR])
  3372. +AM_CONDITIONAL([ENABLE_BASH_COMPLETION],[test "x$with_bash_completion_dir" != "xno"])
  3373. +# ------------------------------------------------------------------------------
  3374. +have_selinux=no
  3375. +AC_ARG_ENABLE(selinux, AS_HELP_STRING([--disable-selinux], [Disable optional SELINUX support]))
  3376. +if test "x$enable_selinux" != "xno"; then
  3377. + PKG_CHECK_MODULES([SELINUX], [libselinux >= 2.1.9],
  3378. + [AC_DEFINE(HAVE_SELINUX, 1, [Define if SELinux is available])
  3379. + have_selinux=yes
  3380. + M4_DEFINES="$M4_DEFINES -DHAVE_SELINUX"],
  3381. + [have_selinux=no])
  3382. + if test "x$have_selinux" = xno -a "x$enable_selinux" = xyes; then
  3383. + AC_MSG_ERROR([*** SELinux support requested but libraries not found])
  3384. + fi
  3385. +fi
  3386. +AM_CONDITIONAL(HAVE_SELINUX, [test "$have_selinux" = "yes"])
  3387. +
  3388. +dnl Keep this in sync with ostree, except remove -Werror=declaration-after-statement
  3389. +CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\
  3390. + -pipe \
  3391. + -Wall \
  3392. + -Werror=empty-body \
  3393. + -Werror=strict-prototypes \
  3394. + -Werror=missing-prototypes \
  3395. + -Werror=implicit-function-declaration \
  3396. + "-Werror=format=2 -Werror=format-security -Werror=format-nonliteral" \
  3397. + -Werror=pointer-arith -Werror=init-self \
  3398. + -Werror=missing-declarations \
  3399. + -Werror=return-type \
  3400. + -Werror=overflow \
  3401. + -Werror=int-conversion \
  3402. + -Werror=parenthesis \
  3403. + -Werror=incompatible-pointer-types \
  3404. + -Werror=misleading-indentation \
  3405. + -Werror=missing-include-dirs -Werror=aggregate-return \
  3406. +])
  3407. +AC_SUBST(WARN_CFLAGS)
  3408. +
  3409. +AC_ARG_WITH(priv-mode,
  3410. + AS_HELP_STRING([--with-priv-mode=setuid/none],
  3411. + [How to set privilege-raising during make install]),
  3412. + [],
  3413. + [with_priv_mode="none"])
  3414. +
  3415. +AM_CONDITIONAL(PRIV_MODE_SETUID, test "x$with_priv_mode" = "xsetuid")
  3416. +
  3417. +AC_ARG_ENABLE(sudo,
  3418. + AS_HELP_STRING([--enable-sudo],[Use sudo to set privileged mode on binaries during install (only needed if --with-priv-mode used)]),
  3419. + [SUDO_BIN="sudo"], [SUDO_BIN=""])
  3420. +AC_SUBST([SUDO_BIN])
  3421. +
  3422. +AC_ARG_ENABLE(require-userns,
  3423. + AS_HELP_STRING([--enable-require-userns=yes/no (default no)],
  3424. + [Require user namespaces by default when installed suid]),
  3425. + [],
  3426. + [enable_require_userns="no"])
  3427. +
  3428. +AS_IF([ test "x$enable_require_userns" = "xyes" ], [
  3429. + AC_DEFINE(ENABLE_REQUIRE_USERNS, 1, [Define if userns should be used by default in suid mode])
  3430. + ])
  3431. +
  3432. +AC_CONFIG_FILES([
  3433. +Makefile
  3434. +])
  3435. +AC_OUTPUT
  3436. +
  3437. +echo "
  3438. + bubblewrap $VERSION
  3439. + ===================
  3440. +
  3441. + man pages (xsltproc): $enable_man
  3442. + SELinux: $have_selinux
  3443. + setuid mode on make install: $with_priv_mode
  3444. + require default userns: $enable_require_userns
  3445. + mysteriously satisfying to pop: yes"
  3446. +echo ""
  3447. diff -Nuar flatpak-1.0.0.orig/bubblewrap/COPYING flatpak-1.0.0/bubblewrap/COPYING
  3448. --- flatpak-1.0.0.orig/bubblewrap/COPYING 1970-01-01 02:00:00.000000000 +0200
  3449. +++ flatpak-1.0.0/bubblewrap/COPYING 2018-02-03 21:26:06.271233339 +0300
  3450. @@ -0,0 +1,481 @@
  3451. + GNU LIBRARY GENERAL PUBLIC LICENSE
  3452. + Version 2, June 1991
  3453. +
  3454. + Copyright (C) 1991 Free Software Foundation, Inc.
  3455. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  3456. + Everyone is permitted to copy and distribute verbatim copies
  3457. + of this license document, but changing it is not allowed.
  3458. +
  3459. +[This is the first released version of the library GPL. It is
  3460. + numbered 2 because it goes with version 2 of the ordinary GPL.]
  3461. +
  3462. + Preamble
  3463. +
  3464. + The licenses for most software are designed to take away your
  3465. +freedom to share and change it. By contrast, the GNU General Public
  3466. +Licenses are intended to guarantee your freedom to share and change
  3467. +free software--to make sure the software is free for all its users.
  3468. +
  3469. + This license, the Library General Public License, applies to some
  3470. +specially designated Free Software Foundation software, and to any
  3471. +other libraries whose authors decide to use it. You can use it for
  3472. +your libraries, too.
  3473. +
  3474. + When we speak of free software, we are referring to freedom, not
  3475. +price. Our General Public Licenses are designed to make sure that you
  3476. +have the freedom to distribute copies of free software (and charge for
  3477. +this service if you wish), that you receive source code or can get it
  3478. +if you want it, that you can change the software or use pieces of it
  3479. +in new free programs; and that you know you can do these things.
  3480. +
  3481. + To protect your rights, we need to make restrictions that forbid
  3482. +anyone to deny you these rights or to ask you to surrender the rights.
  3483. +These restrictions translate to certain responsibilities for you if
  3484. +you distribute copies of the library, or if you modify it.
  3485. +
  3486. + For example, if you distribute copies of the library, whether gratis
  3487. +or for a fee, you must give the recipients all the rights that we gave
  3488. +you. You must make sure that they, too, receive or can get the source
  3489. +code. If you link a program with the library, you must provide
  3490. +complete object files to the recipients so that they can relink them
  3491. +with the library, after making changes to the library and recompiling
  3492. +it. And you must show them these terms so they know their rights.
  3493. +
  3494. + Our method of protecting your rights has two steps: (1) copyright
  3495. +the library, and (2) offer you this license which gives you legal
  3496. +permission to copy, distribute and/or modify the library.
  3497. +
  3498. + Also, for each distributor's protection, we want to make certain
  3499. +that everyone understands that there is no warranty for this free
  3500. +library. If the library is modified by someone else and passed on, we
  3501. +want its recipients to know that what they have is not the original
  3502. +version, so that any problems introduced by others will not reflect on
  3503. +the original authors' reputations.
  3504. +
  3505. + Finally, any free program is threatened constantly by software
  3506. +patents. We wish to avoid the danger that companies distributing free
  3507. +software will individually obtain patent licenses, thus in effect
  3508. +transforming the program into proprietary software. To prevent this,
  3509. +we have made it clear that any patent must be licensed for everyone's
  3510. +free use or not licensed at all.
  3511. +
  3512. + Most GNU software, including some libraries, is covered by the ordinary
  3513. +GNU General Public License, which was designed for utility programs. This
  3514. +license, the GNU Library General Public License, applies to certain
  3515. +designated libraries. This license is quite different from the ordinary
  3516. +one; be sure to read it in full, and don't assume that anything in it is
  3517. +the same as in the ordinary license.
  3518. +
  3519. + The reason we have a separate public license for some libraries is that
  3520. +they blur the distinction we usually make between modifying or adding to a
  3521. +program and simply using it. Linking a program with a library, without
  3522. +changing the library, is in some sense simply using the library, and is
  3523. +analogous to running a utility program or application program. However, in
  3524. +a textual and legal sense, the linked executable is a combined work, a
  3525. +derivative of the original library, and the ordinary General Public License
  3526. +treats it as such.
  3527. +
  3528. + Because of this blurred distinction, using the ordinary General
  3529. +Public License for libraries did not effectively promote software
  3530. +sharing, because most developers did not use the libraries. We
  3531. +concluded that weaker conditions might promote sharing better.
  3532. +
  3533. + However, unrestricted linking of non-free programs would deprive the
  3534. +users of those programs of all benefit from the free status of the
  3535. +libraries themselves. This Library General Public License is intended to
  3536. +permit developers of non-free programs to use free libraries, while
  3537. +preserving your freedom as a user of such programs to change the free
  3538. +libraries that are incorporated in them. (We have not seen how to achieve
  3539. +this as regards changes in header files, but we have achieved it as regards
  3540. +changes in the actual functions of the Library.) The hope is that this
  3541. +will lead to faster development of free libraries.
  3542. +
  3543. + The precise terms and conditions for copying, distribution and
  3544. +modification follow. Pay close attention to the difference between a
  3545. +"work based on the library" and a "work that uses the library". The
  3546. +former contains code derived from the library, while the latter only
  3547. +works together with the library.
  3548. +
  3549. + Note that it is possible for a library to be covered by the ordinary
  3550. +General Public License rather than by this special one.
  3551. +
  3552. + GNU LIBRARY GENERAL PUBLIC LICENSE
  3553. + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  3554. +
  3555. + 0. This License Agreement applies to any software library which
  3556. +contains a notice placed by the copyright holder or other authorized
  3557. +party saying it may be distributed under the terms of this Library
  3558. +General Public License (also called "this License"). Each licensee is
  3559. +addressed as "you".
  3560. +
  3561. + A "library" means a collection of software functions and/or data
  3562. +prepared so as to be conveniently linked with application programs
  3563. +(which use some of those functions and data) to form executables.
  3564. +
  3565. + The "Library", below, refers to any such software library or work
  3566. +which has been distributed under these terms. A "work based on the
  3567. +Library" means either the Library or any derivative work under
  3568. +copyright law: that is to say, a work containing the Library or a
  3569. +portion of it, either verbatim or with modifications and/or translated
  3570. +straightforwardly into another language. (Hereinafter, translation is
  3571. +included without limitation in the term "modification".)
  3572. +
  3573. + "Source code" for a work means the preferred form of the work for
  3574. +making modifications to it. For a library, complete source code means
  3575. +all the source code for all modules it contains, plus any associated
  3576. +interface definition files, plus the scripts used to control compilation
  3577. +and installation of the library.
  3578. +
  3579. + Activities other than copying, distribution and modification are not
  3580. +covered by this License; they are outside its scope. The act of
  3581. +running a program using the Library is not restricted, and output from
  3582. +such a program is covered only if its contents constitute a work based
  3583. +on the Library (independent of the use of the Library in a tool for
  3584. +writing it). Whether that is true depends on what the Library does
  3585. +and what the program that uses the Library does.
  3586. +
  3587. + 1. You may copy and distribute verbatim copies of the Library's
  3588. +complete source code as you receive it, in any medium, provided that
  3589. +you conspicuously and appropriately publish on each copy an
  3590. +appropriate copyright notice and disclaimer of warranty; keep intact
  3591. +all the notices that refer to this License and to the absence of any
  3592. +warranty; and distribute a copy of this License along with the
  3593. +Library.
  3594. +
  3595. + You may charge a fee for the physical act of transferring a copy,
  3596. +and you may at your option offer warranty protection in exchange for a
  3597. +fee.
  3598. +
  3599. + 2. You may modify your copy or copies of the Library or any portion
  3600. +of it, thus forming a work based on the Library, and copy and
  3601. +distribute such modifications or work under the terms of Section 1
  3602. +above, provided that you also meet all of these conditions:
  3603. +
  3604. + a) The modified work must itself be a software library.
  3605. +
  3606. + b) You must cause the files modified to carry prominent notices
  3607. + stating that you changed the files and the date of any change.
  3608. +
  3609. + c) You must cause the whole of the work to be licensed at no
  3610. + charge to all third parties under the terms of this License.
  3611. +
  3612. + d) If a facility in the modified Library refers to a function or a
  3613. + table of data to be supplied by an application program that uses
  3614. + the facility, other than as an argument passed when the facility
  3615. + is invoked, then you must make a good faith effort to ensure that,
  3616. + in the event an application does not supply such function or
  3617. + table, the facility still operates, and performs whatever part of
  3618. + its purpose remains meaningful.
  3619. +
  3620. + (For example, a function in a library to compute square roots has
  3621. + a purpose that is entirely well-defined independent of the
  3622. + application. Therefore, Subsection 2d requires that any
  3623. + application-supplied function or table used by this function must
  3624. + be optional: if the application does not supply it, the square
  3625. + root function must still compute square roots.)
  3626. +
  3627. +These requirements apply to the modified work as a whole. If
  3628. +identifiable sections of that work are not derived from the Library,
  3629. +and can be reasonably considered independent and separate works in
  3630. +themselves, then this License, and its terms, do not apply to those
  3631. +sections when you distribute them as separate works. But when you
  3632. +distribute the same sections as part of a whole which is a work based
  3633. +on the Library, the distribution of the whole must be on the terms of
  3634. +this License, whose permissions for other licensees extend to the
  3635. +entire whole, and thus to each and every part regardless of who wrote
  3636. +it.
  3637. +
  3638. +Thus, it is not the intent of this section to claim rights or contest
  3639. +your rights to work written entirely by you; rather, the intent is to
  3640. +exercise the right to control the distribution of derivative or
  3641. +collective works based on the Library.
  3642. +
  3643. +In addition, mere aggregation of another work not based on the Library
  3644. +with the Library (or with a work based on the Library) on a volume of
  3645. +a storage or distribution medium does not bring the other work under
  3646. +the scope of this License.
  3647. +
  3648. + 3. You may opt to apply the terms of the ordinary GNU General Public
  3649. +License instead of this License to a given copy of the Library. To do
  3650. +this, you must alter all the notices that refer to this License, so
  3651. +that they refer to the ordinary GNU General Public License, version 2,
  3652. +instead of to this License. (If a newer version than version 2 of the
  3653. +ordinary GNU General Public License has appeared, then you can specify
  3654. +that version instead if you wish.) Do not make any other change in
  3655. +these notices.
  3656. +
  3657. + Once this change is made in a given copy, it is irreversible for
  3658. +that copy, so the ordinary GNU General Public License applies to all
  3659. +subsequent copies and derivative works made from that copy.
  3660. +
  3661. + This option is useful when you wish to copy part of the code of
  3662. +the Library into a program that is not a library.
  3663. +
  3664. + 4. You may copy and distribute the Library (or a portion or
  3665. +derivative of it, under Section 2) in object code or executable form
  3666. +under the terms of Sections 1 and 2 above provided that you accompany
  3667. +it with the complete corresponding machine-readable source code, which
  3668. +must be distributed under the terms of Sections 1 and 2 above on a
  3669. +medium customarily used for software interchange.
  3670. +
  3671. + If distribution of object code is made by offering access to copy
  3672. +from a designated place, then offering equivalent access to copy the
  3673. +source code from the same place satisfies the requirement to
  3674. +distribute the source code, even though third parties are not
  3675. +compelled to copy the source along with the object code.
  3676. +
  3677. + 5. A program that contains no derivative of any portion of the
  3678. +Library, but is designed to work with the Library by being compiled or
  3679. +linked with it, is called a "work that uses the Library". Such a
  3680. +work, in isolation, is not a derivative work of the Library, and
  3681. +therefore falls outside the scope of this License.
  3682. +
  3683. + However, linking a "work that uses the Library" with the Library
  3684. +creates an executable that is a derivative of the Library (because it
  3685. +contains portions of the Library), rather than a "work that uses the
  3686. +library". The executable is therefore covered by this License.
  3687. +Section 6 states terms for distribution of such executables.
  3688. +
  3689. + When a "work that uses the Library" uses material from a header file
  3690. +that is part of the Library, the object code for the work may be a
  3691. +derivative work of the Library even though the source code is not.
  3692. +Whether this is true is especially significant if the work can be
  3693. +linked without the Library, or if the work is itself a library. The
  3694. +threshold for this to be true is not precisely defined by law.
  3695. +
  3696. + If such an object file uses only numerical parameters, data
  3697. +structure layouts and accessors, and small macros and small inline
  3698. +functions (ten lines or less in length), then the use of the object
  3699. +file is unrestricted, regardless of whether it is legally a derivative
  3700. +work. (Executables containing this object code plus portions of the
  3701. +Library will still fall under Section 6.)
  3702. +
  3703. + Otherwise, if the work is a derivative of the Library, you may
  3704. +distribute the object code for the work under the terms of Section 6.
  3705. +Any executables containing that work also fall under Section 6,
  3706. +whether or not they are linked directly with the Library itself.
  3707. +
  3708. + 6. As an exception to the Sections above, you may also compile or
  3709. +link a "work that uses the Library" with the Library to produce a
  3710. +work containing portions of the Library, and distribute that work
  3711. +under terms of your choice, provided that the terms permit
  3712. +modification of the work for the customer's own use and reverse
  3713. +engineering for debugging such modifications.
  3714. +
  3715. + You must give prominent notice with each copy of the work that the
  3716. +Library is used in it and that the Library and its use are covered by
  3717. +this License. You must supply a copy of this License. If the work
  3718. +during execution displays copyright notices, you must include the
  3719. +copyright notice for the Library among them, as well as a reference
  3720. +directing the user to the copy of this License. Also, you must do one
  3721. +of these things:
  3722. +
  3723. + a) Accompany the work with the complete corresponding
  3724. + machine-readable source code for the Library including whatever
  3725. + changes were used in the work (which must be distributed under
  3726. + Sections 1 and 2 above); and, if the work is an executable linked
  3727. + with the Library, with the complete machine-readable "work that
  3728. + uses the Library", as object code and/or source code, so that the
  3729. + user can modify the Library and then relink to produce a modified
  3730. + executable containing the modified Library. (It is understood
  3731. + that the user who changes the contents of definitions files in the
  3732. + Library will not necessarily be able to recompile the application
  3733. + to use the modified definitions.)
  3734. +
  3735. + b) Accompany the work with a written offer, valid for at
  3736. + least three years, to give the same user the materials
  3737. + specified in Subsection 6a, above, for a charge no more
  3738. + than the cost of performing this distribution.
  3739. +
  3740. + c) If distribution of the work is made by offering access to copy
  3741. + from a designated place, offer equivalent access to copy the above
  3742. + specified materials from the same place.
  3743. +
  3744. + d) Verify that the user has already received a copy of these
  3745. + materials or that you have already sent this user a copy.
  3746. +
  3747. + For an executable, the required form of the "work that uses the
  3748. +Library" must include any data and utility programs needed for
  3749. +reproducing the executable from it. However, as a special exception,
  3750. +the source code distributed need not include anything that is normally
  3751. +distributed (in either source or binary form) with the major
  3752. +components (compiler, kernel, and so on) of the operating system on
  3753. +which the executable runs, unless that component itself accompanies
  3754. +the executable.
  3755. +
  3756. + It may happen that this requirement contradicts the license
  3757. +restrictions of other proprietary libraries that do not normally
  3758. +accompany the operating system. Such a contradiction means you cannot
  3759. +use both them and the Library together in an executable that you
  3760. +distribute.
  3761. +
  3762. + 7. You may place library facilities that are a work based on the
  3763. +Library side-by-side in a single library together with other library
  3764. +facilities not covered by this License, and distribute such a combined
  3765. +library, provided that the separate distribution of the work based on
  3766. +the Library and of the other library facilities is otherwise
  3767. +permitted, and provided that you do these two things:
  3768. +
  3769. + a) Accompany the combined library with a copy of the same work
  3770. + based on the Library, uncombined with any other library
  3771. + facilities. This must be distributed under the terms of the
  3772. + Sections above.
  3773. +
  3774. + b) Give prominent notice with the combined library of the fact
  3775. + that part of it is a work based on the Library, and explaining
  3776. + where to find the accompanying uncombined form of the same work.
  3777. +
  3778. + 8. You may not copy, modify, sublicense, link with, or distribute
  3779. +the Library except as expressly provided under this License. Any
  3780. +attempt otherwise to copy, modify, sublicense, link with, or
  3781. +distribute the Library is void, and will automatically terminate your
  3782. +rights under this License. However, parties who have received copies,
  3783. +or rights, from you under this License will not have their licenses
  3784. +terminated so long as such parties remain in full compliance.
  3785. +
  3786. + 9. You are not required to accept this License, since you have not
  3787. +signed it. However, nothing else grants you permission to modify or
  3788. +distribute the Library or its derivative works. These actions are
  3789. +prohibited by law if you do not accept this License. Therefore, by
  3790. +modifying or distributing the Library (or any work based on the
  3791. +Library), you indicate your acceptance of this License to do so, and
  3792. +all its terms and conditions for copying, distributing or modifying
  3793. +the Library or works based on it.
  3794. +
  3795. + 10. Each time you redistribute the Library (or any work based on the
  3796. +Library), the recipient automatically receives a license from the
  3797. +original licensor to copy, distribute, link with or modify the Library
  3798. +subject to these terms and conditions. You may not impose any further
  3799. +restrictions on the recipients' exercise of the rights granted herein.
  3800. +You are not responsible for enforcing compliance by third parties to
  3801. +this License.
  3802. +
  3803. + 11. If, as a consequence of a court judgment or allegation of patent
  3804. +infringement or for any other reason (not limited to patent issues),
  3805. +conditions are imposed on you (whether by court order, agreement or
  3806. +otherwise) that contradict the conditions of this License, they do not
  3807. +excuse you from the conditions of this License. If you cannot
  3808. +distribute so as to satisfy simultaneously your obligations under this
  3809. +License and any other pertinent obligations, then as a consequence you
  3810. +may not distribute the Library at all. For example, if a patent
  3811. +license would not permit royalty-free redistribution of the Library by
  3812. +all those who receive copies directly or indirectly through you, then
  3813. +the only way you could satisfy both it and this License would be to
  3814. +refrain entirely from distribution of the Library.
  3815. +
  3816. +If any portion of this section is held invalid or unenforceable under any
  3817. +particular circumstance, the balance of the section is intended to apply,
  3818. +and the section as a whole is intended to apply in other circumstances.
  3819. +
  3820. +It is not the purpose of this section to induce you to infringe any
  3821. +patents or other property right claims or to contest validity of any
  3822. +such claims; this section has the sole purpose of protecting the
  3823. +integrity of the free software distribution system which is
  3824. +implemented by public license practices. Many people have made
  3825. +generous contributions to the wide range of software distributed
  3826. +through that system in reliance on consistent application of that
  3827. +system; it is up to the author/donor to decide if he or she is willing
  3828. +to distribute software through any other system and a licensee cannot
  3829. +impose that choice.
  3830. +
  3831. +This section is intended to make thoroughly clear what is believed to
  3832. +be a consequence of the rest of this License.
  3833. +
  3834. + 12. If the distribution and/or use of the Library is restricted in
  3835. +certain countries either by patents or by copyrighted interfaces, the
  3836. +original copyright holder who places the Library under this License may add
  3837. +an explicit geographical distribution limitation excluding those countries,
  3838. +so that distribution is permitted only in or among countries not thus
  3839. +excluded. In such case, this License incorporates the limitation as if
  3840. +written in the body of this License.
  3841. +
  3842. + 13. The Free Software Foundation may publish revised and/or new
  3843. +versions of the Library General Public License from time to time.
  3844. +Such new versions will be similar in spirit to the present version,
  3845. +but may differ in detail to address new problems or concerns.
  3846. +
  3847. +Each version is given a distinguishing version number. If the Library
  3848. +specifies a version number of this License which applies to it and
  3849. +"any later version", you have the option of following the terms and
  3850. +conditions either of that version or of any later version published by
  3851. +the Free Software Foundation. If the Library does not specify a
  3852. +license version number, you may choose any version ever published by
  3853. +the Free Software Foundation.
  3854. +
  3855. + 14. If you wish to incorporate parts of the Library into other free
  3856. +programs whose distribution conditions are incompatible with these,
  3857. +write to the author to ask for permission. For software which is
  3858. +copyrighted by the Free Software Foundation, write to the Free
  3859. +Software Foundation; we sometimes make exceptions for this. Our
  3860. +decision will be guided by the two goals of preserving the free status
  3861. +of all derivatives of our free software and of promoting the sharing
  3862. +and reuse of software generally.
  3863. +
  3864. + NO WARRANTY
  3865. +
  3866. + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  3867. +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  3868. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  3869. +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  3870. +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  3871. +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  3872. +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  3873. +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  3874. +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  3875. +
  3876. + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  3877. +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  3878. +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  3879. +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  3880. +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  3881. +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  3882. +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  3883. +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  3884. +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  3885. +DAMAGES.
  3886. +
  3887. + END OF TERMS AND CONDITIONS
  3888. +
  3889. + How to Apply These Terms to Your New Libraries
  3890. +
  3891. + If you develop a new library, and you want it to be of the greatest
  3892. +possible use to the public, we recommend making it free software that
  3893. +everyone can redistribute and change. You can do so by permitting
  3894. +redistribution under these terms (or, alternatively, under the terms of the
  3895. +ordinary General Public License).
  3896. +
  3897. + To apply these terms, attach the following notices to the library. It is
  3898. +safest to attach them to the start of each source file to most effectively
  3899. +convey the exclusion of warranty; and each file should have at least the
  3900. +"copyright" line and a pointer to where the full notice is found.
  3901. +
  3902. + <one line to give the library's name and a brief idea of what it does.>
  3903. + Copyright (C) <year> <name of author>
  3904. +
  3905. + This library is free software; you can redistribute it and/or
  3906. + modify it under the terms of the GNU Library General Public
  3907. + License as published by the Free Software Foundation; either
  3908. + version 2 of the License, or (at your option) any later version.
  3909. +
  3910. + This library is distributed in the hope that it will be useful,
  3911. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  3912. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3913. + Library General Public License for more details.
  3914. +
  3915. + You should have received a copy of the GNU Library General Public
  3916. + License along with this library; if not, write to the Free Software
  3917. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  3918. +
  3919. +Also add information on how to contact you by electronic and paper mail.
  3920. +
  3921. +You should also get your employer (if you work as a programmer) or your
  3922. +school, if any, to sign a "copyright disclaimer" for the library, if
  3923. +necessary. Here is a sample; alter the names:
  3924. +
  3925. + Yoyodyne, Inc., hereby disclaims all copyright interest in the
  3926. + library `Frob' (a library for tweaking knobs) written by James Random Hacker.
  3927. +
  3928. + <signature of Ty Coon>, 1 April 1990
  3929. + Ty Coon, President of Vice
  3930. +
  3931. +That's all there is to it!
  3932. diff -Nuar flatpak-1.0.0.orig/bubblewrap/demos/bubblewrap-shell.sh flatpak-1.0.0/bubblewrap/demos/bubblewrap-shell.sh
  3933. --- flatpak-1.0.0.orig/bubblewrap/demos/bubblewrap-shell.sh 1970-01-01 02:00:00.000000000 +0200
  3934. +++ flatpak-1.0.0/bubblewrap/demos/bubblewrap-shell.sh 2018-02-03 21:26:06.273233339 +0300
  3935. @@ -0,0 +1,33 @@
  3936. +#!/usr/bin/env bash
  3937. +# Use bubblewrap to run /bin/sh reusing the host OS binaries (/usr), but with
  3938. +# separate /tmp, /home, /var, /run, and /etc. For /etc we just inherit the
  3939. +# host's resolv.conf, and set up "stub" passwd/group files. Not sharing
  3940. +# /home for example is intentional. If you wanted to, you could design
  3941. +# a bwrap-using program that shared individual parts of /home, perhaps
  3942. +# public content.
  3943. +#
  3944. +# Another way to build on this example is to remove --share-net to disable
  3945. +# networking.
  3946. +set -euo pipefail
  3947. +(exec bwrap --ro-bind /usr /usr \
  3948. + --dir /tmp \
  3949. + --dir /var \
  3950. + --symlink ../tmp var/tmp \
  3951. + --proc /proc \
  3952. + --dev /dev \
  3953. + --ro-bind /etc/resolv.conf /etc/resolv.conf \
  3954. + --symlink usr/lib /lib \
  3955. + --symlink usr/lib64 /lib64 \
  3956. + --symlink usr/bin /bin \
  3957. + --symlink usr/sbin /sbin \
  3958. + --chdir / \
  3959. + --unshare-all \
  3960. + --share-net \
  3961. + --dir /run/user/$(id -u) \
  3962. + --setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
  3963. + --setenv PS1 "bwrap-demo$ " \
  3964. + --file 11 /etc/passwd \
  3965. + --file 12 /etc/group \
  3966. + /bin/sh) \
  3967. + 11< <(getent passwd $UID 65534) \
  3968. + 12< <(getent group $(id -g) 65534)
  3969. diff -Nuar flatpak-1.0.0.orig/bubblewrap/demos/flatpak.bpf flatpak-1.0.0/bubblewrap/demos/flatpak.bpf
  3970. --- flatpak-1.0.0.orig/bubblewrap/demos/flatpak.bpf 1970-01-01 02:00:00.000000000 +0200
  3971. +++ flatpak-1.0.0/bubblewrap/demos/flatpak.bpf 2018-02-03 21:26:06.273233339 +0300
  3972. @@ -0,0 +1,2 @@
  3973. + >>À WeVgU†T‡SšR›Q£P¥O³NíMîLïKJIH*Gg@F‡@Eš@D›@C£@B¥@A³@@í@?î@>ï@=@<@;*@: @9@8ŸØÿÿ38@8 T/2)@ 5*) -) 5 5$ '      @ 3Vg{ƒˆÙ  & 6
  3974. += Pf ax Tÿ
  3975. \ Dosya sonunda yenisatır yok.
  3976. diff -Nuar flatpak-1.0.0.orig/bubblewrap/demos/flatpak-run.sh flatpak-1.0.0/bubblewrap/demos/flatpak-run.sh
  3977. --- flatpak-1.0.0.orig/bubblewrap/demos/flatpak-run.sh 1970-01-01 02:00:00.000000000 +0200
  3978. +++ flatpak-1.0.0/bubblewrap/demos/flatpak-run.sh 2018-02-03 21:26:06.273233339 +0300
  3979. @@ -0,0 +1,65 @@
  3980. +#!/bin/bash
  3981. +# For this to work you first have to run these commands:
  3982. +# curl -O http://sdk.gnome.org/nightly/keys/nightly.gpg
  3983. +# flatpak --user remote-add --gpg-key=nightly.gpg gnome-nightly http://sdk.gnome.org/nightly/repo/
  3984. +# flatpak --user install gnome-nightly org.gnome.Platform
  3985. +# flatpak --user install gnome-nightly org.gnome.Weather
  3986. +
  3987. +mkdir -p ~/.var/app/org.gnome.Weather/cache ~/.var/app/org.gnome.Weather/config ~/.var/app/org.gnome.Weather/data
  3988. +
  3989. +(
  3990. + exec bwrap \
  3991. + --ro-bind ~/.local/share/flatpak/runtime/org.gnome.Platform/x86_64/master/active/files /usr \
  3992. + --lock-file /usr/.ref \
  3993. + --ro-bind ~/.local/share/flatpak/app/org.gnome.Weather/x86_64/master/active/files/ /app \
  3994. + --lock-file /app/.ref \
  3995. + --dev /dev \
  3996. + --proc /proc \
  3997. + --dir /tmp \
  3998. + --symlink /tmp /var/tmp \
  3999. + --symlink /run /var/run \
  4000. + --symlink usr/lib /lib \
  4001. + --symlink usr/lib64 /lib64 \
  4002. + --symlink usr/bin /bin \
  4003. + --symlink usr/sbin /sbin \
  4004. + --symlink usr/etc /etc \
  4005. + --dir /run/user/`id -u` \
  4006. + --ro-bind /etc/machine-id /usr/etc/machine-id \
  4007. + --ro-bind /etc/resolv.conf /run/host/monitor/resolv.conf \
  4008. + --ro-bind /sys/block /sys/block \
  4009. + --ro-bind /sys/bus /sys/bus \
  4010. + --ro-bind /sys/class /sys/class \
  4011. + --ro-bind /sys/dev /sys/dev \
  4012. + --ro-bind /sys/devices /sys/devices \
  4013. + --dev-bind /dev/dri /dev/dri \
  4014. + --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X99 \
  4015. + --bind ~/.var/app/org.gnome.Weather ~/.var/app/org.gnome.Weather \
  4016. + --bind ~/.config/dconf ~/.config/dconf \
  4017. + --bind /run/user/`id -u`/dconf /run/user/`id -u`/dconf \
  4018. + --unshare-pid \
  4019. + --setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
  4020. + --setenv DISPLAY :99 \
  4021. + --setenv GI_TYPELIB_PATH /app/lib/girepository-1.0 \
  4022. + --setenv GST_PLUGIN_PATH /app/lib/gstreamer-1.0 \
  4023. + --setenv LD_LIBRARY_PATH /app/lib:/usr/lib/GL \
  4024. + --setenv DCONF_USER_CONFIG_DIR .config/dconf \
  4025. + --setenv PATH /app/bin:/usr/bin \
  4026. + --setenv XDG_CONFIG_DIRS /app/etc/xdg:/etc/xdg \
  4027. + --setenv XDG_DATA_DIRS /app/share:/usr/share \
  4028. + --setenv SHELL /bin/sh \
  4029. + --setenv XDG_CACHE_HOME ~/.var/app/org.gnome.Weather/cache \
  4030. + --setenv XDG_CONFIG_HOME ~/.var/app/org.gnome.Weather/config \
  4031. + --setenv XDG_DATA_HOME ~/.var/app/org.gnome.Weather/data \
  4032. + --file 10 /run/user/`id -u`/flatpak-info \
  4033. + --bind-data 11 /usr/etc/passwd \
  4034. + --bind-data 12 /usr/etc/group \
  4035. + --seccomp 13 \
  4036. + /bin/sh) \
  4037. + 11< <(getent passwd $UID 65534 ) \
  4038. + 12< <(getent group $(id -g) 65534) \
  4039. + 13< `dirname $0`/flatpak.bpf \
  4040. + 10<<EOF
  4041. +[Application]
  4042. +name=org.gnome.Weather
  4043. +runtime=runtime/org.gnome.Platform/x86_64/master
  4044. +EOF
  4045. diff -Nuar flatpak-1.0.0.orig/bubblewrap/.dir-locals.el flatpak-1.0.0/bubblewrap/.dir-locals.el
  4046. --- flatpak-1.0.0.orig/bubblewrap/.dir-locals.el 1970-01-01 02:00:00.000000000 +0200
  4047. +++ flatpak-1.0.0/bubblewrap/.dir-locals.el 2018-02-03 21:26:06.271233339 +0300
  4048. @@ -0,0 +1 @@
  4049. +((c-mode . ((indent-tabs-mode . nil) (c-file-style . "gnu"))))
  4050. diff -Nuar flatpak-1.0.0.orig/bubblewrap/.editorconfig flatpak-1.0.0/bubblewrap/.editorconfig
  4051. --- flatpak-1.0.0.orig/bubblewrap/.editorconfig 1970-01-01 02:00:00.000000000 +0200
  4052. +++ flatpak-1.0.0/bubblewrap/.editorconfig 2018-02-03 21:26:06.271233339 +0300
  4053. @@ -0,0 +1,6 @@
  4054. +[*.[ch]]
  4055. +indent_style = space
  4056. +indent_size = 2
  4057. +trim_trailing_whitespace = true
  4058. +indent_brace_style = gnu
  4059. +
  4060. diff -Nuar flatpak-1.0.0.orig/bubblewrap/.git flatpak-1.0.0/bubblewrap/.git
  4061. --- flatpak-1.0.0.orig/bubblewrap/.git 1970-01-01 02:00:00.000000000 +0200
  4062. +++ flatpak-1.0.0/bubblewrap/.git 2018-02-03 21:25:59.242232860 +0300
  4063. @@ -0,0 +1 @@
  4064. +gitdir: ../.git/modules/bubblewrap
  4065. diff -Nuar flatpak-1.0.0.orig/bubblewrap/git.mk flatpak-1.0.0/bubblewrap/git.mk
  4066. --- flatpak-1.0.0.orig/bubblewrap/git.mk 1970-01-01 02:00:00.000000000 +0200
  4067. +++ flatpak-1.0.0/bubblewrap/git.mk 2018-02-03 21:26:06.273233339 +0300
  4068. @@ -0,0 +1,348 @@
  4069. +# git.mk, a small Makefile to autogenerate .gitignore files
  4070. +# for autotools-based projects.
  4071. +#
  4072. +# Copyright 2009, Red Hat, Inc.
  4073. +# Copyright 2010,2011,2012,2013 Behdad Esfahbod
  4074. +# Written by Behdad Esfahbod
  4075. +#
  4076. +# Copying and distribution of this file, with or without modification,
  4077. +# is permitted in any medium without royalty provided the copyright
  4078. +# notice and this notice are preserved.
  4079. +#
  4080. +# The latest version of this file can be downloaded from:
  4081. +GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk
  4082. +#
  4083. +# Bugs, etc, should be reported upstream at:
  4084. +# https://github.com/behdad/git.mk
  4085. +#
  4086. +# To use in your project, import this file in your git repo's toplevel,
  4087. +# then do "make -f git.mk". This modifies all Makefile.am files in
  4088. +# your project to -include git.mk. Remember to add that line to new
  4089. +# Makefile.am files you create in your project, or just rerun the
  4090. +# "make -f git.mk".
  4091. +#
  4092. +# This enables automatic .gitignore generation. If you need to ignore
  4093. +# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
  4094. +# But think twice before doing that. If a file has to be in .gitignore,
  4095. +# chances are very high that it's a generated file and should be in one
  4096. +# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
  4097. +#
  4098. +# The only case that you need to manually add a file to GITIGNOREFILES is
  4099. +# when remove files in one of mostlyclean-local, clean-local, distclean-local,
  4100. +# or maintainer-clean-local make targets.
  4101. +#
  4102. +# Note that for files like editor backup, etc, there are better places to
  4103. +# ignore them. See "man gitignore".
  4104. +#
  4105. +# If "make maintainer-clean" removes the files but they are not recognized
  4106. +# by this script (that is, if "git status" shows untracked files still), send
  4107. +# me the output of "git status" as well as your Makefile.am and Makefile for
  4108. +# the directories involved and I'll diagnose.
  4109. +#
  4110. +# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
  4111. +# Makefile.am.sample in the git.mk git repo.
  4112. +#
  4113. +# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
  4114. +# not tarballs. It serves no useful purpose in tarballs and clutters the
  4115. +# build dir.
  4116. +#
  4117. +# This file knows how to handle autoconf, automake, libtool, gtk-doc,
  4118. +# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
  4119. +# appstream.
  4120. +#
  4121. +# This makefile provides the following targets:
  4122. +#
  4123. +# - all: "make all" will build all gitignore files.
  4124. +# - gitignore: makes all gitignore files in the current dir and subdirs.
  4125. +# - .gitignore: make gitignore file for the current dir.
  4126. +# - gitignore-recurse: makes all gitignore files in the subdirs.
  4127. +#
  4128. +# KNOWN ISSUES:
  4129. +#
  4130. +# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
  4131. +# submodule doesn't find us. If you have configure.{in,ac} files in
  4132. +# subdirs, add a proxy git.mk file in those dirs that simply does:
  4133. +# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
  4134. +# And add those files to git. See vte/gnome-pty-helper/git.mk for
  4135. +# example.
  4136. +#
  4137. +
  4138. +
  4139. +
  4140. +###############################################################################
  4141. +# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
  4142. +###############################################################################
  4143. +
  4144. +#
  4145. +# Most autotools-using modules should be fine including this variable in their
  4146. +# toplevel MAINTAINERCLEANFILES:
  4147. +GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
  4148. + $(srcdir)/aclocal.m4 \
  4149. + $(srcdir)/autoscan.log \
  4150. + $(srcdir)/configure.scan \
  4151. + `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
  4152. + test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
  4153. + for x in \
  4154. + ar-lib \
  4155. + compile \
  4156. + config.guess \
  4157. + config.sub \
  4158. + depcomp \
  4159. + install-sh \
  4160. + ltmain.sh \
  4161. + missing \
  4162. + mkinstalldirs \
  4163. + test-driver \
  4164. + ylwrap \
  4165. + ; do echo "$$AUX_DIR/$$x"; done` \
  4166. + `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
  4167. + head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
  4168. +#
  4169. +# All modules should also be fine including the following variable, which
  4170. +# removes automake-generated Makefile.in files:
  4171. +GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
  4172. + `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
  4173. + while read f; do \
  4174. + case $$f in Makefile|*/Makefile) \
  4175. + test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
  4176. + done`
  4177. +#
  4178. +# Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
  4179. +# though it's harmless to include regardless.
  4180. +GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
  4181. + `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
  4182. + if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
  4183. + for x in \
  4184. + libtool.m4 \
  4185. + ltoptions.m4 \
  4186. + ltsugar.m4 \
  4187. + ltversion.m4 \
  4188. + lt~obsolete.m4 \
  4189. + ; do echo "$$MACRO_DIR/$$x"; done; \
  4190. + fi`
  4191. +
  4192. +
  4193. +
  4194. +###############################################################################
  4195. +# Default rule is to install ourselves in all Makefile.am files:
  4196. +###############################################################################
  4197. +
  4198. +git-all: git-mk-install
  4199. +
  4200. +git-mk-install:
  4201. + @echo "Installing git makefile"
  4202. + @any_failed=; \
  4203. + find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
  4204. + if grep 'include .*/git.mk' $$x >/dev/null; then \
  4205. + echo "$$x already includes git.mk"; \
  4206. + else \
  4207. + failed=; \
  4208. + echo "Updating $$x"; \
  4209. + { cat $$x; \
  4210. + echo ''; \
  4211. + echo '-include $$(top_srcdir)/git.mk'; \
  4212. + } > $$x.tmp || failed=1; \
  4213. + if test x$$failed = x; then \
  4214. + mv $$x.tmp $$x || failed=1; \
  4215. + fi; \
  4216. + if test x$$failed = x; then : else \
  4217. + echo "Failed updating $$x"; >&2 \
  4218. + any_failed=1; \
  4219. + fi; \
  4220. + fi; done; test -z "$$any_failed"
  4221. +
  4222. +git-mk-update:
  4223. + wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
  4224. +
  4225. +.PHONY: git-all git-mk-install git-mk-update
  4226. +
  4227. +
  4228. +
  4229. +###############################################################################
  4230. +# Actual .gitignore generation:
  4231. +###############################################################################
  4232. +
  4233. +$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
  4234. + @echo "git.mk: Generating $@"
  4235. + @{ \
  4236. + if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
  4237. + for x in \
  4238. + $(DOC_MODULE)-decl-list.txt \
  4239. + $(DOC_MODULE)-decl.txt \
  4240. + tmpl/$(DOC_MODULE)-unused.sgml \
  4241. + "tmpl/*.bak" \
  4242. + $(REPORT_FILES) \
  4243. + $(DOC_MODULE).pdf \
  4244. + xml html \
  4245. + ; do echo "/$$x"; done; \
  4246. + FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
  4247. + case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
  4248. + if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \
  4249. + echo "/$(DOC_MODULE).types"; \
  4250. + fi; \
  4251. + if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \
  4252. + echo "/$(DOC_MODULE)-sections.txt"; \
  4253. + fi; \
  4254. + if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
  4255. + for x in \
  4256. + $(SETUP_FILES) \
  4257. + $(DOC_MODULE).types \
  4258. + ; do echo "/$$x"; done; \
  4259. + fi; \
  4260. + fi; \
  4261. + if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
  4262. + for lc in $(DOC_LINGUAS); do \
  4263. + for x in \
  4264. + $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
  4265. + $(DOC_PAGES) \
  4266. + $(DOC_INCLUDES) \
  4267. + ; do echo "/$$lc/$$x"; done; \
  4268. + done; \
  4269. + for x in \
  4270. + $(_DOC_OMF_ALL) \
  4271. + $(_DOC_DSK_ALL) \
  4272. + $(_DOC_HTML_ALL) \
  4273. + $(_DOC_MOFILES) \
  4274. + $(DOC_H_FILE) \
  4275. + "*/.xml2po.mo" \
  4276. + "*/*.omf.out" \
  4277. + ; do echo /$$x; done; \
  4278. + fi; \
  4279. + if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
  4280. + for lc in $(HELP_LINGUAS); do \
  4281. + for x in \
  4282. + $(HELP_FILES) \
  4283. + "$$lc.stamp" \
  4284. + "$$lc.mo" \
  4285. + ; do echo "/$$lc/$$x"; done; \
  4286. + done; \
  4287. + fi; \
  4288. + if test "x$(gsettings_SCHEMAS)" = x; then :; else \
  4289. + for x in \
  4290. + $(gsettings_SCHEMAS:.xml=.valid) \
  4291. + $(gsettings__enum_file) \
  4292. + ; do echo "/$$x"; done; \
  4293. + fi; \
  4294. + if test "x$(appdata_XML)" = x; then :; else \
  4295. + for x in \
  4296. + $(appdata_XML:.xml=.valid) \
  4297. + ; do echo "/$$x"; done; \
  4298. + fi; \
  4299. + if test "x$(appstream_XML)" = x; then :; else \
  4300. + for x in \
  4301. + $(appstream_XML:.xml=.valid) \
  4302. + ; do echo "/$$x"; done; \
  4303. + fi; \
  4304. + if test -f $(srcdir)/po/Makefile.in.in; then \
  4305. + for x in \
  4306. + po/Makefile.in.in \
  4307. + po/Makefile.in.in~ \
  4308. + po/Makefile.in \
  4309. + po/Makefile \
  4310. + po/Makevars.template \
  4311. + po/POTFILES \
  4312. + po/Rules-quot \
  4313. + po/stamp-it \
  4314. + po/stamp-po \
  4315. + po/.intltool-merge-cache \
  4316. + "po/*.gmo" \
  4317. + "po/*.header" \
  4318. + "po/*.mo" \
  4319. + "po/*.sed" \
  4320. + "po/*.sin" \
  4321. + po/$(GETTEXT_PACKAGE).pot \
  4322. + intltool-extract.in \
  4323. + intltool-merge.in \
  4324. + intltool-update.in \
  4325. + ; do echo "/$$x"; done; \
  4326. + fi; \
  4327. + if test -f $(srcdir)/configure; then \
  4328. + for x in \
  4329. + autom4te.cache \
  4330. + configure \
  4331. + config.h \
  4332. + stamp-h1 \
  4333. + libtool \
  4334. + config.lt \
  4335. + ; do echo "/$$x"; done; \
  4336. + fi; \
  4337. + if test "x$(DEJATOOL)" = x; then :; else \
  4338. + for x in \
  4339. + $(DEJATOOL) \
  4340. + ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
  4341. + echo /site.exp; \
  4342. + fi; \
  4343. + if test "x$(am__dirstamp)" = x; then :; else \
  4344. + echo "$(am__dirstamp)"; \
  4345. + fi; \
  4346. + if test "x$(LTCOMPILE)" = x -a "x$(LTCXXCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
  4347. + for x in \
  4348. + "*.lo" \
  4349. + ".libs" "_libs" \
  4350. + ; do echo "$$x"; done; \
  4351. + fi; \
  4352. + for x in \
  4353. + .gitignore \
  4354. + $(GITIGNOREFILES) \
  4355. + $(CLEANFILES) \
  4356. + $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
  4357. + $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
  4358. + $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
  4359. + so_locations \
  4360. + $(MOSTLYCLEANFILES) \
  4361. + $(TEST_LOGS) \
  4362. + $(TEST_LOGS:.log=.trs) \
  4363. + $(TEST_SUITE_LOG) \
  4364. + $(TESTS:=.test) \
  4365. + "*.gcda" \
  4366. + "*.gcno" \
  4367. + $(DISTCLEANFILES) \
  4368. + $(am__CONFIG_DISTCLEAN_FILES) \
  4369. + $(CONFIG_CLEAN_FILES) \
  4370. + TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
  4371. + "*.tab.c" \
  4372. + $(MAINTAINERCLEANFILES) \
  4373. + $(BUILT_SOURCES) \
  4374. + $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
  4375. + $(filter %_vala.stamp,$(DIST_COMMON)) \
  4376. + $(filter %.vapi,$(DIST_COMMON)) \
  4377. + $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
  4378. + Makefile \
  4379. + Makefile.in \
  4380. + "*.orig" \
  4381. + "*.rej" \
  4382. + "*.bak" \
  4383. + "*~" \
  4384. + ".*.sw[nop]" \
  4385. + ".dirstamp" \
  4386. + ; do echo "/$$x"; done; \
  4387. + for x in \
  4388. + "*.$(OBJEXT)" \
  4389. + $(DEPDIR) \
  4390. + ; do echo "$$x"; done; \
  4391. + } | \
  4392. + sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
  4393. + sed 's@/[.]/@/@g' | \
  4394. + LC_ALL=C sort | uniq > $@.tmp && \
  4395. + mv $@.tmp $@;
  4396. +
  4397. +all: $(srcdir)/.gitignore gitignore-recurse-maybe
  4398. +gitignore: $(srcdir)/.gitignore gitignore-recurse
  4399. +
  4400. +gitignore-recurse-maybe:
  4401. + @for subdir in $(DIST_SUBDIRS); do \
  4402. + case " $(SUBDIRS) " in \
  4403. + *" $$subdir "*) :;; \
  4404. + *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
  4405. + esac; \
  4406. + done
  4407. +gitignore-recurse:
  4408. + @for subdir in $(DIST_SUBDIRS); do \
  4409. + test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
  4410. + done
  4411. +
  4412. +maintainer-clean: gitignore-clean
  4413. +gitignore-clean:
  4414. + -rm -f $(srcdir)/.gitignore
  4415. +
  4416. +.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
  4417. diff -Nuar flatpak-1.0.0.orig/bubblewrap/LICENSE flatpak-1.0.0/bubblewrap/LICENSE
  4418. --- flatpak-1.0.0.orig/bubblewrap/LICENSE 1970-01-01 02:00:00.000000000 +0200
  4419. +++ flatpak-1.0.0/bubblewrap/LICENSE 2018-02-03 21:26:06.271233339 +0300
  4420. @@ -0,0 +1,481 @@
  4421. + GNU LIBRARY GENERAL PUBLIC LICENSE
  4422. + Version 2, June 1991
  4423. +
  4424. + Copyright (C) 1991 Free Software Foundation, Inc.
  4425. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  4426. + Everyone is permitted to copy and distribute verbatim copies
  4427. + of this license document, but changing it is not allowed.
  4428. +
  4429. +[This is the first released version of the library GPL. It is
  4430. + numbered 2 because it goes with version 2 of the ordinary GPL.]
  4431. +
  4432. + Preamble
  4433. +
  4434. + The licenses for most software are designed to take away your
  4435. +freedom to share and change it. By contrast, the GNU General Public
  4436. +Licenses are intended to guarantee your freedom to share and change
  4437. +free software--to make sure the software is free for all its users.
  4438. +
  4439. + This license, the Library General Public License, applies to some
  4440. +specially designated Free Software Foundation software, and to any
  4441. +other libraries whose authors decide to use it. You can use it for
  4442. +your libraries, too.
  4443. +
  4444. + When we speak of free software, we are referring to freedom, not
  4445. +price. Our General Public Licenses are designed to make sure that you
  4446. +have the freedom to distribute copies of free software (and charge for
  4447. +this service if you wish), that you receive source code or can get it
  4448. +if you want it, that you can change the software or use pieces of it
  4449. +in new free programs; and that you know you can do these things.
  4450. +
  4451. + To protect your rights, we need to make restrictions that forbid
  4452. +anyone to deny you these rights or to ask you to surrender the rights.
  4453. +These restrictions translate to certain responsibilities for you if
  4454. +you distribute copies of the library, or if you modify it.
  4455. +
  4456. + For example, if you distribute copies of the library, whether gratis
  4457. +or for a fee, you must give the recipients all the rights that we gave
  4458. +you. You must make sure that they, too, receive or can get the source
  4459. +code. If you link a program with the library, you must provide
  4460. +complete object files to the recipients so that they can relink them
  4461. +with the library, after making changes to the library and recompiling
  4462. +it. And you must show them these terms so they know their rights.
  4463. +
  4464. + Our method of protecting your rights has two steps: (1) copyright
  4465. +the library, and (2) offer you this license which gives you legal
  4466. +permission to copy, distribute and/or modify the library.
  4467. +
  4468. + Also, for each distributor's protection, we want to make certain
  4469. +that everyone understands that there is no warranty for this free
  4470. +library. If the library is modified by someone else and passed on, we
  4471. +want its recipients to know that what they have is not the original
  4472. +version, so that any problems introduced by others will not reflect on
  4473. +the original authors' reputations.
  4474. +
  4475. + Finally, any free program is threatened constantly by software
  4476. +patents. We wish to avoid the danger that companies distributing free
  4477. +software will individually obtain patent licenses, thus in effect
  4478. +transforming the program into proprietary software. To prevent this,
  4479. +we have made it clear that any patent must be licensed for everyone's
  4480. +free use or not licensed at all.
  4481. +
  4482. + Most GNU software, including some libraries, is covered by the ordinary
  4483. +GNU General Public License, which was designed for utility programs. This
  4484. +license, the GNU Library General Public License, applies to certain
  4485. +designated libraries. This license is quite different from the ordinary
  4486. +one; be sure to read it in full, and don't assume that anything in it is
  4487. +the same as in the ordinary license.
  4488. +
  4489. + The reason we have a separate public license for some libraries is that
  4490. +they blur the distinction we usually make between modifying or adding to a
  4491. +program and simply using it. Linking a program with a library, without
  4492. +changing the library, is in some sense simply using the library, and is
  4493. +analogous to running a utility program or application program. However, in
  4494. +a textual and legal sense, the linked executable is a combined work, a
  4495. +derivative of the original library, and the ordinary General Public License
  4496. +treats it as such.
  4497. +
  4498. + Because of this blurred distinction, using the ordinary General
  4499. +Public License for libraries did not effectively promote software
  4500. +sharing, because most developers did not use the libraries. We
  4501. +concluded that weaker conditions might promote sharing better.
  4502. +
  4503. + However, unrestricted linking of non-free programs would deprive the
  4504. +users of those programs of all benefit from the free status of the
  4505. +libraries themselves. This Library General Public License is intended to
  4506. +permit developers of non-free programs to use free libraries, while
  4507. +preserving your freedom as a user of such programs to change the free
  4508. +libraries that are incorporated in them. (We have not seen how to achieve
  4509. +this as regards changes in header files, but we have achieved it as regards
  4510. +changes in the actual functions of the Library.) The hope is that this
  4511. +will lead to faster development of free libraries.
  4512. +
  4513. + The precise terms and conditions for copying, distribution and
  4514. +modification follow. Pay close attention to the difference between a
  4515. +"work based on the library" and a "work that uses the library". The
  4516. +former contains code derived from the library, while the latter only
  4517. +works together with the library.
  4518. +
  4519. + Note that it is possible for a library to be covered by the ordinary
  4520. +General Public License rather than by this special one.
  4521. +
  4522. + GNU LIBRARY GENERAL PUBLIC LICENSE
  4523. + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  4524. +
  4525. + 0. This License Agreement applies to any software library which
  4526. +contains a notice placed by the copyright holder or other authorized
  4527. +party saying it may be distributed under the terms of this Library
  4528. +General Public License (also called "this License"). Each licensee is
  4529. +addressed as "you".
  4530. +
  4531. + A "library" means a collection of software functions and/or data
  4532. +prepared so as to be conveniently linked with application programs
  4533. +(which use some of those functions and data) to form executables.
  4534. +
  4535. + The "Library", below, refers to any such software library or work
  4536. +which has been distributed under these terms. A "work based on the
  4537. +Library" means either the Library or any derivative work under
  4538. +copyright law: that is to say, a work containing the Library or a
  4539. +portion of it, either verbatim or with modifications and/or translated
  4540. +straightforwardly into another language. (Hereinafter, translation is
  4541. +included without limitation in the term "modification".)
  4542. +
  4543. + "Source code" for a work means the preferred form of the work for
  4544. +making modifications to it. For a library, complete source code means
  4545. +all the source code for all modules it contains, plus any associated
  4546. +interface definition files, plus the scripts used to control compilation
  4547. +and installation of the library.
  4548. +
  4549. + Activities other than copying, distribution and modification are not
  4550. +covered by this License; they are outside its scope. The act of
  4551. +running a program using the Library is not restricted, and output from
  4552. +such a program is covered only if its contents constitute a work based
  4553. +on the Library (independent of the use of the Library in a tool for
  4554. +writing it). Whether that is true depends on what the Library does
  4555. +and what the program that uses the Library does.
  4556. +
  4557. + 1. You may copy and distribute verbatim copies of the Library's
  4558. +complete source code as you receive it, in any medium, provided that
  4559. +you conspicuously and appropriately publish on each copy an
  4560. +appropriate copyright notice and disclaimer of warranty; keep intact
  4561. +all the notices that refer to this License and to the absence of any
  4562. +warranty; and distribute a copy of this License along with the
  4563. +Library.
  4564. +
  4565. + You may charge a fee for the physical act of transferring a copy,
  4566. +and you may at your option offer warranty protection in exchange for a
  4567. +fee.
  4568. +
  4569. + 2. You may modify your copy or copies of the Library or any portion
  4570. +of it, thus forming a work based on the Library, and copy and
  4571. +distribute such modifications or work under the terms of Section 1
  4572. +above, provided that you also meet all of these conditions:
  4573. +
  4574. + a) The modified work must itself be a software library.
  4575. +
  4576. + b) You must cause the files modified to carry prominent notices
  4577. + stating that you changed the files and the date of any change.
  4578. +
  4579. + c) You must cause the whole of the work to be licensed at no
  4580. + charge to all third parties under the terms of this License.
  4581. +
  4582. + d) If a facility in the modified Library refers to a function or a
  4583. + table of data to be supplied by an application program that uses
  4584. + the facility, other than as an argument passed when the facility
  4585. + is invoked, then you must make a good faith effort to ensure that,
  4586. + in the event an application does not supply such function or
  4587. + table, the facility still operates, and performs whatever part of
  4588. + its purpose remains meaningful.
  4589. +
  4590. + (For example, a function in a library to compute square roots has
  4591. + a purpose that is entirely well-defined independent of the
  4592. + application. Therefore, Subsection 2d requires that any
  4593. + application-supplied function or table used by this function must
  4594. + be optional: if the application does not supply it, the square
  4595. + root function must still compute square roots.)
  4596. +
  4597. +These requirements apply to the modified work as a whole. If
  4598. +identifiable sections of that work are not derived from the Library,
  4599. +and can be reasonably considered independent and separate works in
  4600. +themselves, then this License, and its terms, do not apply to those
  4601. +sections when you distribute them as separate works. But when you
  4602. +distribute the same sections as part of a whole which is a work based
  4603. +on the Library, the distribution of the whole must be on the terms of
  4604. +this License, whose permissions for other licensees extend to the
  4605. +entire whole, and thus to each and every part regardless of who wrote
  4606. +it.
  4607. +
  4608. +Thus, it is not the intent of this section to claim rights or contest
  4609. +your rights to work written entirely by you; rather, the intent is to
  4610. +exercise the right to control the distribution of derivative or
  4611. +collective works based on the Library.
  4612. +
  4613. +In addition, mere aggregation of another work not based on the Library
  4614. +with the Library (or with a work based on the Library) on a volume of
  4615. +a storage or distribution medium does not bring the other work under
  4616. +the scope of this License.
  4617. +
  4618. + 3. You may opt to apply the terms of the ordinary GNU General Public
  4619. +License instead of this License to a given copy of the Library. To do
  4620. +this, you must alter all the notices that refer to this License, so
  4621. +that they refer to the ordinary GNU General Public License, version 2,
  4622. +instead of to this License. (If a newer version than version 2 of the
  4623. +ordinary GNU General Public License has appeared, then you can specify
  4624. +that version instead if you wish.) Do not make any other change in
  4625. +these notices.
  4626. +
  4627. + Once this change is made in a given copy, it is irreversible for
  4628. +that copy, so the ordinary GNU General Public License applies to all
  4629. +subsequent copies and derivative works made from that copy.
  4630. +
  4631. + This option is useful when you wish to copy part of the code of
  4632. +the Library into a program that is not a library.
  4633. +
  4634. + 4. You may copy and distribute the Library (or a portion or
  4635. +derivative of it, under Section 2) in object code or executable form
  4636. +under the terms of Sections 1 and 2 above provided that you accompany
  4637. +it with the complete corresponding machine-readable source code, which
  4638. +must be distributed under the terms of Sections 1 and 2 above on a
  4639. +medium customarily used for software interchange.
  4640. +
  4641. + If distribution of object code is made by offering access to copy
  4642. +from a designated place, then offering equivalent access to copy the
  4643. +source code from the same place satisfies the requirement to
  4644. +distribute the source code, even though third parties are not
  4645. +compelled to copy the source along with the object code.
  4646. +
  4647. + 5. A program that contains no derivative of any portion of the
  4648. +Library, but is designed to work with the Library by being compiled or
  4649. +linked with it, is called a "work that uses the Library". Such a
  4650. +work, in isolation, is not a derivative work of the Library, and
  4651. +therefore falls outside the scope of this License.
  4652. +
  4653. + However, linking a "work that uses the Library" with the Library
  4654. +creates an executable that is a derivative of the Library (because it
  4655. +contains portions of the Library), rather than a "work that uses the
  4656. +library". The executable is therefore covered by this License.
  4657. +Section 6 states terms for distribution of such executables.
  4658. +
  4659. + When a "work that uses the Library" uses material from a header file
  4660. +that is part of the Library, the object code for the work may be a
  4661. +derivative work of the Library even though the source code is not.
  4662. +Whether this is true is especially significant if the work can be
  4663. +linked without the Library, or if the work is itself a library. The
  4664. +threshold for this to be true is not precisely defined by law.
  4665. +
  4666. + If such an object file uses only numerical parameters, data
  4667. +structure layouts and accessors, and small macros and small inline
  4668. +functions (ten lines or less in length), then the use of the object
  4669. +file is unrestricted, regardless of whether it is legally a derivative
  4670. +work. (Executables containing this object code plus portions of the
  4671. +Library will still fall under Section 6.)
  4672. +
  4673. + Otherwise, if the work is a derivative of the Library, you may
  4674. +distribute the object code for the work under the terms of Section 6.
  4675. +Any executables containing that work also fall under Section 6,
  4676. +whether or not they are linked directly with the Library itself.
  4677. +
  4678. + 6. As an exception to the Sections above, you may also compile or
  4679. +link a "work that uses the Library" with the Library to produce a
  4680. +work containing portions of the Library, and distribute that work
  4681. +under terms of your choice, provided that the terms permit
  4682. +modification of the work for the customer's own use and reverse
  4683. +engineering for debugging such modifications.
  4684. +
  4685. + You must give prominent notice with each copy of the work that the
  4686. +Library is used in it and that the Library and its use are covered by
  4687. +this License. You must supply a copy of this License. If the work
  4688. +during execution displays copyright notices, you must include the
  4689. +copyright notice for the Library among them, as well as a reference
  4690. +directing the user to the copy of this License. Also, you must do one
  4691. +of these things:
  4692. +
  4693. + a) Accompany the work with the complete corresponding
  4694. + machine-readable source code for the Library including whatever
  4695. + changes were used in the work (which must be distributed under
  4696. + Sections 1 and 2 above); and, if the work is an executable linked
  4697. + with the Library, with the complete machine-readable "work that
  4698. + uses the Library", as object code and/or source code, so that the
  4699. + user can modify the Library and then relink to produce a modified
  4700. + executable containing the modified Library. (It is understood
  4701. + that the user who changes the contents of definitions files in the
  4702. + Library will not necessarily be able to recompile the application
  4703. + to use the modified definitions.)
  4704. +
  4705. + b) Accompany the work with a written offer, valid for at
  4706. + least three years, to give the same user the materials
  4707. + specified in Subsection 6a, above, for a charge no more
  4708. + than the cost of performing this distribution.
  4709. +
  4710. + c) If distribution of the work is made by offering access to copy
  4711. + from a designated place, offer equivalent access to copy the above
  4712. + specified materials from the same place.
  4713. +
  4714. + d) Verify that the user has already received a copy of these
  4715. + materials or that you have already sent this user a copy.
  4716. +
  4717. + For an executable, the required form of the "work that uses the
  4718. +Library" must include any data and utility programs needed for
  4719. +reproducing the executable from it. However, as a special exception,
  4720. +the source code distributed need not include anything that is normally
  4721. +distributed (in either source or binary form) with the major
  4722. +components (compiler, kernel, and so on) of the operating system on
  4723. +which the executable runs, unless that component itself accompanies
  4724. +the executable.
  4725. +
  4726. + It may happen that this requirement contradicts the license
  4727. +restrictions of other proprietary libraries that do not normally
  4728. +accompany the operating system. Such a contradiction means you cannot
  4729. +use both them and the Library together in an executable that you
  4730. +distribute.
  4731. +
  4732. + 7. You may place library facilities that are a work based on the
  4733. +Library side-by-side in a single library together with other library
  4734. +facilities not covered by this License, and distribute such a combined
  4735. +library, provided that the separate distribution of the work based on
  4736. +the Library and of the other library facilities is otherwise
  4737. +permitted, and provided that you do these two things:
  4738. +
  4739. + a) Accompany the combined library with a copy of the same work
  4740. + based on the Library, uncombined with any other library
  4741. + facilities. This must be distributed under the terms of the
  4742. + Sections above.
  4743. +
  4744. + b) Give prominent notice with the combined library of the fact
  4745. + that part of it is a work based on the Library, and explaining
  4746. + where to find the accompanying uncombined form of the same work.
  4747. +
  4748. + 8. You may not copy, modify, sublicense, link with, or distribute
  4749. +the Library except as expressly provided under this License. Any
  4750. +attempt otherwise to copy, modify, sublicense, link with, or
  4751. +distribute the Library is void, and will automatically terminate your
  4752. +rights under this License. However, parties who have received copies,
  4753. +or rights, from you under this License will not have their licenses
  4754. +terminated so long as such parties remain in full compliance.
  4755. +
  4756. + 9. You are not required to accept this License, since you have not
  4757. +signed it. However, nothing else grants you permission to modify or
  4758. +distribute the Library or its derivative works. These actions are
  4759. +prohibited by law if you do not accept this License. Therefore, by
  4760. +modifying or distributing the Library (or any work based on the
  4761. +Library), you indicate your acceptance of this License to do so, and
  4762. +all its terms and conditions for copying, distributing or modifying
  4763. +the Library or works based on it.
  4764. +
  4765. + 10. Each time you redistribute the Library (or any work based on the
  4766. +Library), the recipient automatically receives a license from the
  4767. +original licensor to copy, distribute, link with or modify the Library
  4768. +subject to these terms and conditions. You may not impose any further
  4769. +restrictions on the recipients' exercise of the rights granted herein.
  4770. +You are not responsible for enforcing compliance by third parties to
  4771. +this License.
  4772. +
  4773. + 11. If, as a consequence of a court judgment or allegation of patent
  4774. +infringement or for any other reason (not limited to patent issues),
  4775. +conditions are imposed on you (whether by court order, agreement or
  4776. +otherwise) that contradict the conditions of this License, they do not
  4777. +excuse you from the conditions of this License. If you cannot
  4778. +distribute so as to satisfy simultaneously your obligations under this
  4779. +License and any other pertinent obligations, then as a consequence you
  4780. +may not distribute the Library at all. For example, if a patent
  4781. +license would not permit royalty-free redistribution of the Library by
  4782. +all those who receive copies directly or indirectly through you, then
  4783. +the only way you could satisfy both it and this License would be to
  4784. +refrain entirely from distribution of the Library.
  4785. +
  4786. +If any portion of this section is held invalid or unenforceable under any
  4787. +particular circumstance, the balance of the section is intended to apply,
  4788. +and the section as a whole is intended to apply in other circumstances.
  4789. +
  4790. +It is not the purpose of this section to induce you to infringe any
  4791. +patents or other property right claims or to contest validity of any
  4792. +such claims; this section has the sole purpose of protecting the
  4793. +integrity of the free software distribution system which is
  4794. +implemented by public license practices. Many people have made
  4795. +generous contributions to the wide range of software distributed
  4796. +through that system in reliance on consistent application of that
  4797. +system; it is up to the author/donor to decide if he or she is willing
  4798. +to distribute software through any other system and a licensee cannot
  4799. +impose that choice.
  4800. +
  4801. +This section is intended to make thoroughly clear what is believed to
  4802. +be a consequence of the rest of this License.
  4803. +
  4804. + 12. If the distribution and/or use of the Library is restricted in
  4805. +certain countries either by patents or by copyrighted interfaces, the
  4806. +original copyright holder who places the Library under this License may add
  4807. +an explicit geographical distribution limitation excluding those countries,
  4808. +so that distribution is permitted only in or among countries not thus
  4809. +excluded. In such case, this License incorporates the limitation as if
  4810. +written in the body of this License.
  4811. +
  4812. + 13. The Free Software Foundation may publish revised and/or new
  4813. +versions of the Library General Public License from time to time.
  4814. +Such new versions will be similar in spirit to the present version,
  4815. +but may differ in detail to address new problems or concerns.
  4816. +
  4817. +Each version is given a distinguishing version number. If the Library
  4818. +specifies a version number of this License which applies to it and
  4819. +"any later version", you have the option of following the terms and
  4820. +conditions either of that version or of any later version published by
  4821. +the Free Software Foundation. If the Library does not specify a
  4822. +license version number, you may choose any version ever published by
  4823. +the Free Software Foundation.
  4824. +
  4825. + 14. If you wish to incorporate parts of the Library into other free
  4826. +programs whose distribution conditions are incompatible with these,
  4827. +write to the author to ask for permission. For software which is
  4828. +copyrighted by the Free Software Foundation, write to the Free
  4829. +Software Foundation; we sometimes make exceptions for this. Our
  4830. +decision will be guided by the two goals of preserving the free status
  4831. +of all derivatives of our free software and of promoting the sharing
  4832. +and reuse of software generally.
  4833. +
  4834. + NO WARRANTY
  4835. +
  4836. + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  4837. +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  4838. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  4839. +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  4840. +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  4841. +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  4842. +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  4843. +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  4844. +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  4845. +
  4846. + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  4847. +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  4848. +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  4849. +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  4850. +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  4851. +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  4852. +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  4853. +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  4854. +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  4855. +DAMAGES.
  4856. +
  4857. + END OF TERMS AND CONDITIONS
  4858. +
  4859. + How to Apply These Terms to Your New Libraries
  4860. +
  4861. + If you develop a new library, and you want it to be of the greatest
  4862. +possible use to the public, we recommend making it free software that
  4863. +everyone can redistribute and change. You can do so by permitting
  4864. +redistribution under these terms (or, alternatively, under the terms of the
  4865. +ordinary General Public License).
  4866. +
  4867. + To apply these terms, attach the following notices to the library. It is
  4868. +safest to attach them to the start of each source file to most effectively
  4869. +convey the exclusion of warranty; and each file should have at least the
  4870. +"copyright" line and a pointer to where the full notice is found.
  4871. +
  4872. + <one line to give the library's name and a brief idea of what it does.>
  4873. + Copyright (C) <year> <name of author>
  4874. +
  4875. + This library is free software; you can redistribute it and/or
  4876. + modify it under the terms of the GNU Library General Public
  4877. + License as published by the Free Software Foundation; either
  4878. + version 2 of the License, or (at your option) any later version.
  4879. +
  4880. + This library is distributed in the hope that it will be useful,
  4881. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  4882. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4883. + Library General Public License for more details.
  4884. +
  4885. + You should have received a copy of the GNU Library General Public
  4886. + License along with this library; if not, write to the Free Software
  4887. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  4888. +
  4889. +Also add information on how to contact you by electronic and paper mail.
  4890. +
  4891. +You should also get your employer (if you work as a programmer) or your
  4892. +school, if any, to sign a "copyright disclaimer" for the library, if
  4893. +necessary. Here is a sample; alter the names:
  4894. +
  4895. + Yoyodyne, Inc., hereby disclaims all copyright interest in the
  4896. + library `Frob' (a library for tweaking knobs) written by James Random Hacker.
  4897. +
  4898. + <signature of Ty Coon>, 1 April 1990
  4899. + Ty Coon, President of Vice
  4900. +
  4901. +That's all there is to it!
  4902. diff -Nuar flatpak-1.0.0.orig/bubblewrap/m4/attributes.m4 flatpak-1.0.0/bubblewrap/m4/attributes.m4
  4903. --- flatpak-1.0.0.orig/bubblewrap/m4/attributes.m4 1970-01-01 02:00:00.000000000 +0200
  4904. +++ flatpak-1.0.0/bubblewrap/m4/attributes.m4 2018-02-03 21:26:06.273233339 +0300
  4905. @@ -0,0 +1,292 @@
  4906. +dnl Macros to check the presence of generic (non-typed) symbols.
  4907. +dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
  4908. +dnl Copyright (c) 2006-2008 xine project
  4909. +dnl Copyright (c) 2012 Lucas De Marchi <lucas.de.marchi@gmail.com>
  4910. +dnl
  4911. +dnl This program is free software; you can redistribute it and/or modify
  4912. +dnl it under the terms of the GNU General Public License as published by
  4913. +dnl the Free Software Foundation; either version 2, or (at your option)
  4914. +dnl any later version.
  4915. +dnl
  4916. +dnl This program is distributed in the hope that it will be useful,
  4917. +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
  4918. +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  4919. +dnl GNU General Public License for more details.
  4920. +dnl
  4921. +dnl You should have received a copy of the GNU General Public License
  4922. +dnl along with this program; if not, write to the Free Software
  4923. +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  4924. +dnl 02110-1301, USA.
  4925. +dnl
  4926. +dnl As a special exception, the copyright owners of the
  4927. +dnl macro gives unlimited permission to copy, distribute and modify the
  4928. +dnl configure scripts that are the output of Autoconf when processing the
  4929. +dnl Macro. You need not follow the terms of the GNU General Public
  4930. +dnl License when using or distributing such scripts, even though portions
  4931. +dnl of the text of the Macro appear in them. The GNU General Public
  4932. +dnl License (GPL) does govern all other use of the material that
  4933. +dnl constitutes the Autoconf Macro.
  4934. +dnl
  4935. +dnl This special exception to the GPL applies to versions of the
  4936. +dnl Autoconf Macro released by this project. When you make and
  4937. +dnl distribute a modified version of the Autoconf Macro, you may extend
  4938. +dnl this special exception to the GPL to apply to your modified version as
  4939. +dnl well.
  4940. +
  4941. +dnl Check if FLAG in ENV-VAR is supported by compiler and append it
  4942. +dnl to WHERE-TO-APPEND variable. Note that we invert -Wno-* checks to
  4943. +dnl -W* as gcc cannot test for negated warnings. If a C snippet is passed,
  4944. +dnl use it, otherwise use a simple main() definition that just returns 0.
  4945. +dnl CC_CHECK_FLAG_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG], [C-SNIPPET])
  4946. +
  4947. +AC_DEFUN([CC_CHECK_FLAG_APPEND], [
  4948. + AC_CACHE_CHECK([if $CC supports flag $3 in envvar $2],
  4949. + AS_TR_SH([cc_cv_$2_$3]),
  4950. + [eval "AS_TR_SH([cc_save_$2])='${$2}'"
  4951. + eval "AS_TR_SH([$2])='${cc_save_$2} -Werror `echo "$3" | sed 's/^-Wno-/-W/'`'"
  4952. + AC_LINK_IFELSE([AC_LANG_SOURCE(ifelse([$4], [],
  4953. + [int main(void) { return 0; } ],
  4954. + [$4]))],
  4955. + [eval "AS_TR_SH([cc_cv_$2_$3])='yes'"],
  4956. + [eval "AS_TR_SH([cc_cv_$2_$3])='no'"])
  4957. + eval "AS_TR_SH([$2])='$cc_save_$2'"])
  4958. +
  4959. + AS_IF([eval test x$]AS_TR_SH([cc_cv_$2_$3])[ = xyes],
  4960. + [eval "$1='${$1} $3'"])
  4961. +])
  4962. +
  4963. +dnl CC_CHECK_FLAGS_APPEND([WHERE-TO-APPEND], [ENV-VAR], [FLAG1 FLAG2], [C-SNIPPET])
  4964. +AC_DEFUN([CC_CHECK_FLAGS_APPEND], [
  4965. + for flag in [$3]; do
  4966. + CC_CHECK_FLAG_APPEND([$1], [$2], $flag, [$4])
  4967. + done
  4968. +])
  4969. +
  4970. +dnl Check if the flag is supported by linker (cacheable)
  4971. +dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  4972. +
  4973. +AC_DEFUN([CC_CHECK_LDFLAGS], [
  4974. + AC_CACHE_CHECK([if $CC supports $1 flag],
  4975. + AS_TR_SH([cc_cv_ldflags_$1]),
  4976. + [ac_save_LDFLAGS="$LDFLAGS"
  4977. + LDFLAGS="$LDFLAGS $1"
  4978. + AC_LINK_IFELSE([int main() { return 1; }],
  4979. + [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
  4980. + [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
  4981. + LDFLAGS="$ac_save_LDFLAGS"
  4982. + ])
  4983. +
  4984. + AS_IF([eval test x$]AS_TR_SH([cc_cv_ldflags_$1])[ = xyes],
  4985. + [$2], [$3])
  4986. +])
  4987. +
  4988. +dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
  4989. +dnl the current linker to avoid undefined references in a shared object.
  4990. +AC_DEFUN([CC_NOUNDEFINED], [
  4991. + dnl We check $host for which systems to enable this for.
  4992. + AC_REQUIRE([AC_CANONICAL_HOST])
  4993. +
  4994. + case $host in
  4995. + dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
  4996. + dnl are requested, as different implementations are present; to avoid problems
  4997. + dnl use -Wl,-z,defs only for those platform not behaving this way.
  4998. + *-freebsd* | *-openbsd*) ;;
  4999. + *)
  5000. + dnl First of all check for the --no-undefined variant of GNU ld. This allows
  5001. + dnl for a much more readable command line, so that people can understand what
  5002. + dnl it does without going to look for what the heck -z defs does.
  5003. + for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
  5004. + CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
  5005. + break
  5006. + done
  5007. + ;;
  5008. + esac
  5009. +
  5010. + AC_SUBST([LDFLAGS_NOUNDEFINED])
  5011. +])
  5012. +
  5013. +dnl Check for a -Werror flag or equivalent. -Werror is the GCC
  5014. +dnl and ICC flag that tells the compiler to treat all the warnings
  5015. +dnl as fatal. We usually need this option to make sure that some
  5016. +dnl constructs (like attributes) are not simply ignored.
  5017. +dnl
  5018. +dnl Other compilers don't support -Werror per se, but they support
  5019. +dnl an equivalent flag:
  5020. +dnl - Sun Studio compiler supports -errwarn=%all
  5021. +AC_DEFUN([CC_CHECK_WERROR], [
  5022. + AC_CACHE_CHECK(
  5023. + [for $CC way to treat warnings as errors],
  5024. + [cc_cv_werror],
  5025. + [CC_CHECK_CFLAGS_SILENT([-Werror], [cc_cv_werror=-Werror],
  5026. + [CC_CHECK_CFLAGS_SILENT([-errwarn=%all], [cc_cv_werror=-errwarn=%all])])
  5027. + ])
  5028. +])
  5029. +
  5030. +AC_DEFUN([CC_CHECK_ATTRIBUTE], [
  5031. + AC_REQUIRE([CC_CHECK_WERROR])
  5032. + AC_CACHE_CHECK([if $CC supports __attribute__(( ifelse([$2], , [$1], [$2]) ))],
  5033. + AS_TR_SH([cc_cv_attribute_$1]),
  5034. + [ac_save_CFLAGS="$CFLAGS"
  5035. + CFLAGS="$CFLAGS $cc_cv_werror"
  5036. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([$3])],
  5037. + [eval "AS_TR_SH([cc_cv_attribute_$1])='yes'"],
  5038. + [eval "AS_TR_SH([cc_cv_attribute_$1])='no'"])
  5039. + CFLAGS="$ac_save_CFLAGS"
  5040. + ])
  5041. +
  5042. + AS_IF([eval test x$]AS_TR_SH([cc_cv_attribute_$1])[ = xyes],
  5043. + [AC_DEFINE(
  5044. + AS_TR_CPP([SUPPORT_ATTRIBUTE_$1]), 1,
  5045. + [Define this if the compiler supports __attribute__(( ifelse([$2], , [$1], [$2]) ))]
  5046. + )
  5047. + $4],
  5048. + [$5])
  5049. +])
  5050. +
  5051. +AC_DEFUN([CC_ATTRIBUTE_CONSTRUCTOR], [
  5052. + CC_CHECK_ATTRIBUTE(
  5053. + [constructor],,
  5054. + [void __attribute__((constructor)) ctor() { int a; }],
  5055. + [$1], [$2])
  5056. +])
  5057. +
  5058. +AC_DEFUN([CC_ATTRIBUTE_FORMAT], [
  5059. + CC_CHECK_ATTRIBUTE(
  5060. + [format], [format(printf, n, n)],
  5061. + [void __attribute__((format(printf, 1, 2))) printflike(const char *fmt, ...) { fmt = (void *)0; }],
  5062. + [$1], [$2])
  5063. +])
  5064. +
  5065. +AC_DEFUN([CC_ATTRIBUTE_FORMAT_ARG], [
  5066. + CC_CHECK_ATTRIBUTE(
  5067. + [format_arg], [format_arg(printf)],
  5068. + [char *__attribute__((format_arg(1))) gettextlike(const char *fmt) { fmt = (void *)0; }],
  5069. + [$1], [$2])
  5070. +])
  5071. +
  5072. +AC_DEFUN([CC_ATTRIBUTE_VISIBILITY], [
  5073. + CC_CHECK_ATTRIBUTE(
  5074. + [visibility_$1], [visibility("$1")],
  5075. + [void __attribute__((visibility("$1"))) $1_function() { }],
  5076. + [$2], [$3])
  5077. +])
  5078. +
  5079. +AC_DEFUN([CC_ATTRIBUTE_NONNULL], [
  5080. + CC_CHECK_ATTRIBUTE(
  5081. + [nonnull], [nonnull()],
  5082. + [void __attribute__((nonnull())) some_function(void *foo, void *bar) { foo = (void*)0; bar = (void*)0; }],
  5083. + [$1], [$2])
  5084. +])
  5085. +
  5086. +AC_DEFUN([CC_ATTRIBUTE_UNUSED], [
  5087. + CC_CHECK_ATTRIBUTE(
  5088. + [unused], ,
  5089. + [void some_function(void *foo, __attribute__((unused)) void *bar);],
  5090. + [$1], [$2])
  5091. +])
  5092. +
  5093. +AC_DEFUN([CC_ATTRIBUTE_SENTINEL], [
  5094. + CC_CHECK_ATTRIBUTE(
  5095. + [sentinel], ,
  5096. + [void some_function(void *foo, ...) __attribute__((sentinel));],
  5097. + [$1], [$2])
  5098. +])
  5099. +
  5100. +AC_DEFUN([CC_ATTRIBUTE_DEPRECATED], [
  5101. + CC_CHECK_ATTRIBUTE(
  5102. + [deprecated], ,
  5103. + [void some_function(void *foo, ...) __attribute__((deprecated));],
  5104. + [$1], [$2])
  5105. +])
  5106. +
  5107. +AC_DEFUN([CC_ATTRIBUTE_ALIAS], [
  5108. + CC_CHECK_ATTRIBUTE(
  5109. + [alias], [weak, alias],
  5110. + [void other_function(void *foo) { }
  5111. + void some_function(void *foo) __attribute__((weak, alias("other_function")));],
  5112. + [$1], [$2])
  5113. +])
  5114. +
  5115. +AC_DEFUN([CC_ATTRIBUTE_MALLOC], [
  5116. + CC_CHECK_ATTRIBUTE(
  5117. + [malloc], ,
  5118. + [void * __attribute__((malloc)) my_alloc(int n);],
  5119. + [$1], [$2])
  5120. +])
  5121. +
  5122. +AC_DEFUN([CC_ATTRIBUTE_PACKED], [
  5123. + CC_CHECK_ATTRIBUTE(
  5124. + [packed], ,
  5125. + [struct astructure { char a; int b; long c; void *d; } __attribute__((packed));],
  5126. + [$1], [$2])
  5127. +])
  5128. +
  5129. +AC_DEFUN([CC_ATTRIBUTE_CONST], [
  5130. + CC_CHECK_ATTRIBUTE(
  5131. + [const], ,
  5132. + [int __attribute__((const)) twopow(int n) { return 1 << n; } ],
  5133. + [$1], [$2])
  5134. +])
  5135. +
  5136. +AC_DEFUN([CC_FLAG_VISIBILITY], [
  5137. + AC_REQUIRE([CC_CHECK_WERROR])
  5138. + AC_CACHE_CHECK([if $CC supports -fvisibility=hidden],
  5139. + [cc_cv_flag_visibility],
  5140. + [cc_flag_visibility_save_CFLAGS="$CFLAGS"
  5141. + CFLAGS="$CFLAGS $cc_cv_werror"
  5142. + CC_CHECK_CFLAGS_SILENT([-fvisibility=hidden],
  5143. + cc_cv_flag_visibility='yes',
  5144. + cc_cv_flag_visibility='no')
  5145. + CFLAGS="$cc_flag_visibility_save_CFLAGS"])
  5146. +
  5147. + AS_IF([test "x$cc_cv_flag_visibility" = "xyes"],
  5148. + [AC_DEFINE([SUPPORT_FLAG_VISIBILITY], 1,
  5149. + [Define this if the compiler supports the -fvisibility flag])
  5150. + $1],
  5151. + [$2])
  5152. +])
  5153. +
  5154. +AC_DEFUN([CC_FUNC_EXPECT], [
  5155. + AC_REQUIRE([CC_CHECK_WERROR])
  5156. + AC_CACHE_CHECK([if compiler has __builtin_expect function],
  5157. + [cc_cv_func_expect],
  5158. + [ac_save_CFLAGS="$CFLAGS"
  5159. + CFLAGS="$CFLAGS $cc_cv_werror"
  5160. + AC_COMPILE_IFELSE([AC_LANG_SOURCE(
  5161. + [int some_function() {
  5162. + int a = 3;
  5163. + return (int)__builtin_expect(a, 3);
  5164. + }])],
  5165. + [cc_cv_func_expect=yes],
  5166. + [cc_cv_func_expect=no])
  5167. + CFLAGS="$ac_save_CFLAGS"
  5168. + ])
  5169. +
  5170. + AS_IF([test "x$cc_cv_func_expect" = "xyes"],
  5171. + [AC_DEFINE([SUPPORT__BUILTIN_EXPECT], 1,
  5172. + [Define this if the compiler supports __builtin_expect() function])
  5173. + $1],
  5174. + [$2])
  5175. +])
  5176. +
  5177. +AC_DEFUN([CC_ATTRIBUTE_ALIGNED], [
  5178. + AC_REQUIRE([CC_CHECK_WERROR])
  5179. + AC_CACHE_CHECK([highest __attribute__ ((aligned ())) supported],
  5180. + [cc_cv_attribute_aligned],
  5181. + [ac_save_CFLAGS="$CFLAGS"
  5182. + CFLAGS="$CFLAGS $cc_cv_werror"
  5183. + for cc_attribute_align_try in 64 32 16 8 4 2; do
  5184. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([
  5185. + int main() {
  5186. + static char c __attribute__ ((aligned($cc_attribute_align_try))) = 0;
  5187. + return c;
  5188. + }])], [cc_cv_attribute_aligned=$cc_attribute_align_try; break])
  5189. + done
  5190. + CFLAGS="$ac_save_CFLAGS"
  5191. + ])
  5192. +
  5193. + if test "x$cc_cv_attribute_aligned" != "x"; then
  5194. + AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], [$cc_cv_attribute_aligned],
  5195. + [Define the highest alignment supported])
  5196. + fi
  5197. +])
  5198. diff -Nuar flatpak-1.0.0.orig/bubblewrap/Makefile.am flatpak-1.0.0/bubblewrap/Makefile.am
  5199. --- flatpak-1.0.0.orig/bubblewrap/Makefile.am 1970-01-01 02:00:00.000000000 +0200
  5200. +++ flatpak-1.0.0/bubblewrap/Makefile.am 2018-02-03 21:26:06.271233339 +0300
  5201. @@ -0,0 +1,46 @@
  5202. +AM_CFLAGS = $(WARN_CFLAGS)
  5203. +CLEANFILES =
  5204. +EXTRA_DIST =
  5205. +
  5206. +GITIGNOREFILES = build-aux/ gtk-doc.make config.h.in aclocal.m4
  5207. +
  5208. +bin_PROGRAMS = bwrap
  5209. +
  5210. +bwrap_srcpath := $(srcdir)
  5211. +include Makefile-bwrap.am
  5212. +
  5213. +install-exec-hook:
  5214. +if PRIV_MODE_SETUID
  5215. + $(SUDO_BIN) chown root $(DESTDIR)$(bindir)/bwrap
  5216. + $(SUDO_BIN) chmod u+s $(DESTDIR)$(bindir)/bwrap
  5217. +endif
  5218. +
  5219. +check_PROGRAMS = test-bwrap
  5220. +
  5221. +test-bwrap: bwrap
  5222. + rm -rf test-bwrap
  5223. + cp bwrap test-bwrap
  5224. +if PRIV_MODE_SETUID
  5225. + $(SUDO_BIN) chown root test-bwrap
  5226. + $(SUDO_BIN) chmod u+s test-bwrap
  5227. +endif
  5228. +
  5229. +test_bwrap_SOURCES=
  5230. +
  5231. +include Makefile-docs.am
  5232. +
  5233. +TESTS = tests/test-run.sh
  5234. +TESTS_ENVIRONMENT = BWRAP=$(abs_top_builddir)/test-bwrap
  5235. +
  5236. +EXTRA_DIST += $(TESTS)
  5237. +
  5238. +if ENABLE_BASH_COMPLETION
  5239. +bashcompletiondir = $(BASH_COMPLETION_DIR)
  5240. +dist_bashcompletion_DATA = completions/bash/bwrap
  5241. +endif
  5242. +
  5243. +-include $(top_srcdir)/git.mk
  5244. +
  5245. +AM_DISTCHECK_CONFIGURE_FLAGS = \
  5246. + --with-bash-completion-dir="\$(datadir)"/bash-completion/ \
  5247. + $(NULL)
  5248. diff -Nuar flatpak-1.0.0.orig/bubblewrap/Makefile-bwrap.am flatpak-1.0.0/bubblewrap/Makefile-bwrap.am
  5249. --- flatpak-1.0.0.orig/bubblewrap/Makefile-bwrap.am 1970-01-01 02:00:00.000000000 +0200
  5250. +++ flatpak-1.0.0/bubblewrap/Makefile-bwrap.am 2018-02-03 21:26:06.271233339 +0300
  5251. @@ -0,0 +1,13 @@
  5252. +
  5253. +bwrap_SOURCES = \
  5254. + $(bwrap_srcpath)/bubblewrap.c \
  5255. + $(bwrap_srcpath)/bind-mount.h \
  5256. + $(bwrap_srcpath)/bind-mount.c \
  5257. + $(bwrap_srcpath)/network.h \
  5258. + $(bwrap_srcpath)/network.c \
  5259. + $(bwrap_srcpath)/utils.h \
  5260. + $(bwrap_srcpath)/utils.c \
  5261. + $(NULL)
  5262. +
  5263. +bwrap_CFLAGS = $(AM_CFLAGS)
  5264. +bwrap_LDADD = $(SELINUX_LIBS)
  5265. diff -Nuar flatpak-1.0.0.orig/bubblewrap/Makefile-docs.am flatpak-1.0.0/bubblewrap/Makefile-docs.am
  5266. --- flatpak-1.0.0.orig/bubblewrap/Makefile-docs.am 1970-01-01 02:00:00.000000000 +0200
  5267. +++ flatpak-1.0.0/bubblewrap/Makefile-docs.am 2018-02-03 21:26:06.271233339 +0300
  5268. @@ -0,0 +1,18 @@
  5269. +XSLTPROC = xsltproc
  5270. +
  5271. +XSLTPROC_FLAGS = \
  5272. + --nonet \
  5273. + --stringparam man.output.quietly 1 \
  5274. + --stringparam funcsynopsis.style ansi \
  5275. + --stringparam man.th.extra1.suppress 1 \
  5276. + --stringparam man.authors.section.enabled 0 \
  5277. + --stringparam man.copyright.section.enabled 0
  5278. +
  5279. +.xml.1:
  5280. + $(XSLTPROC) $(XSLTPROC_FLAGS) http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
  5281. +
  5282. +if ENABLE_MAN
  5283. +man_MANS = bwrap.1
  5284. +CLEANFILES += $(man_MANS)
  5285. +endif
  5286. +EXTRA_DIST += bwrap.xml
  5287. diff -Nuar flatpak-1.0.0.orig/bubblewrap/network.c flatpak-1.0.0/bubblewrap/network.c
  5288. --- flatpak-1.0.0.orig/bubblewrap/network.c 1970-01-01 02:00:00.000000000 +0200
  5289. +++ flatpak-1.0.0/bubblewrap/network.c 2018-02-03 21:26:06.273233339 +0300
  5290. @@ -0,0 +1,198 @@
  5291. +/* bubblewrap
  5292. + * Copyright (C) 2016 Alexander Larsson
  5293. + *
  5294. + * This program is free software; you can redistribute it and/or
  5295. + * modify it under the terms of the GNU Lesser General Public
  5296. + * License as published by the Free Software Foundation; either
  5297. + * version 2 of the License, or (at your option) any later version.
  5298. + *
  5299. + * This library is distributed in the hope that it will be useful,
  5300. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5301. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5302. + * Lesser General Public License for more details.
  5303. + *
  5304. + * You should have received a copy of the GNU Lesser General Public
  5305. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  5306. + *
  5307. + */
  5308. +
  5309. +#include "config.h"
  5310. +
  5311. +#include <arpa/inet.h>
  5312. +#include <net/if.h>
  5313. +#include <netinet/in.h>
  5314. +#include <linux/loop.h>
  5315. +#include <linux/netlink.h>
  5316. +#include <linux/rtnetlink.h>
  5317. +
  5318. +#include "utils.h"
  5319. +#include "network.h"
  5320. +
  5321. +static void *
  5322. +add_rta (struct nlmsghdr *header,
  5323. + int type,
  5324. + size_t size)
  5325. +{
  5326. + struct rtattr *rta;
  5327. + size_t rta_size = RTA_LENGTH (size);
  5328. +
  5329. + rta = (struct rtattr *) ((char *) header + NLMSG_ALIGN (header->nlmsg_len));
  5330. + rta->rta_type = type;
  5331. + rta->rta_len = rta_size;
  5332. +
  5333. + header->nlmsg_len = NLMSG_ALIGN (header->nlmsg_len) + rta_size;
  5334. +
  5335. + return RTA_DATA (rta);
  5336. +}
  5337. +
  5338. +static int
  5339. +rtnl_send_request (int rtnl_fd,
  5340. + struct nlmsghdr *header)
  5341. +{
  5342. + struct sockaddr_nl dst_addr = { AF_NETLINK, 0 };
  5343. + ssize_t sent;
  5344. +
  5345. + sent = sendto (rtnl_fd, (void *) header, header->nlmsg_len, 0,
  5346. + (struct sockaddr *) &dst_addr, sizeof (dst_addr));
  5347. + if (sent < 0)
  5348. + return -1;
  5349. +
  5350. + return 0;
  5351. +}
  5352. +
  5353. +static int
  5354. +rtnl_read_reply (int rtnl_fd,
  5355. + int seq_nr)
  5356. +{
  5357. + char buffer[1024];
  5358. + ssize_t received;
  5359. + struct nlmsghdr *rheader;
  5360. +
  5361. + while (1)
  5362. + {
  5363. + received = recv (rtnl_fd, buffer, sizeof (buffer), 0);
  5364. + if (received < 0)
  5365. + return -1;
  5366. +
  5367. + rheader = (struct nlmsghdr *) buffer;
  5368. + while (received >= NLMSG_HDRLEN)
  5369. + {
  5370. + if (rheader->nlmsg_seq != seq_nr)
  5371. + return -1;
  5372. + if (rheader->nlmsg_pid != getpid ())
  5373. + return -1;
  5374. + if (rheader->nlmsg_type == NLMSG_ERROR)
  5375. + {
  5376. + uint32_t *err = NLMSG_DATA (rheader);
  5377. + if (*err == 0)
  5378. + return 0;
  5379. +
  5380. + return -1;
  5381. + }
  5382. + if (rheader->nlmsg_type == NLMSG_DONE)
  5383. + return 0;
  5384. +
  5385. + rheader = NLMSG_NEXT (rheader, received);
  5386. + }
  5387. + }
  5388. +}
  5389. +
  5390. +static int
  5391. +rtnl_do_request (int rtnl_fd,
  5392. + struct nlmsghdr *header)
  5393. +{
  5394. + if (rtnl_send_request (rtnl_fd, header) != 0)
  5395. + return -1;
  5396. +
  5397. + if (rtnl_read_reply (rtnl_fd, header->nlmsg_seq) != 0)
  5398. + return -1;
  5399. +
  5400. + return 0;
  5401. +}
  5402. +
  5403. +static struct nlmsghdr *
  5404. +rtnl_setup_request (char *buffer,
  5405. + int type,
  5406. + int flags,
  5407. + size_t size)
  5408. +{
  5409. + struct nlmsghdr *header;
  5410. + size_t len = NLMSG_LENGTH (size);
  5411. + static uint32_t counter = 0;
  5412. +
  5413. + memset (buffer, 0, len);
  5414. +
  5415. + header = (struct nlmsghdr *) buffer;
  5416. + header->nlmsg_len = len;
  5417. + header->nlmsg_type = type;
  5418. + header->nlmsg_flags = flags | NLM_F_REQUEST;
  5419. + header->nlmsg_seq = counter++;
  5420. + header->nlmsg_pid = getpid ();
  5421. +
  5422. + return (struct nlmsghdr *) header;
  5423. +}
  5424. +
  5425. +void
  5426. +loopback_setup (void)
  5427. +{
  5428. + int r, if_loopback;
  5429. + cleanup_fd int rtnl_fd = -1;
  5430. + char buffer[1024];
  5431. + struct sockaddr_nl src_addr = { AF_NETLINK, 0 };
  5432. + struct nlmsghdr *header;
  5433. + struct ifaddrmsg *addmsg;
  5434. + struct ifinfomsg *infomsg;
  5435. + struct in_addr *ip_addr;
  5436. +
  5437. + src_addr.nl_pid = getpid ();
  5438. +
  5439. + if_loopback = (int) if_nametoindex ("lo");
  5440. + if (if_loopback <= 0)
  5441. + die_with_error ("loopback: Failed to look up lo");
  5442. +
  5443. + rtnl_fd = socket (PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
  5444. + if (rtnl_fd < 0)
  5445. + die_with_error ("loopback: Failed to create NETLINK_ROUTE socket");
  5446. +
  5447. + r = bind (rtnl_fd, (struct sockaddr *) &src_addr, sizeof (src_addr));
  5448. + if (r < 0)
  5449. + die_with_error ("loopback: Failed to bind NETLINK_ROUTE socket");
  5450. +
  5451. + header = rtnl_setup_request (buffer, RTM_NEWADDR,
  5452. + NLM_F_CREATE | NLM_F_EXCL | NLM_F_ACK,
  5453. + sizeof (struct ifaddrmsg));
  5454. + addmsg = NLMSG_DATA (header);
  5455. +
  5456. + addmsg->ifa_family = AF_INET;
  5457. + addmsg->ifa_prefixlen = 8;
  5458. + addmsg->ifa_flags = IFA_F_PERMANENT;
  5459. + addmsg->ifa_scope = RT_SCOPE_HOST;
  5460. + addmsg->ifa_index = if_loopback;
  5461. +
  5462. + ip_addr = add_rta (header, IFA_LOCAL, sizeof (*ip_addr));
  5463. + ip_addr->s_addr = htonl (INADDR_LOOPBACK);
  5464. +
  5465. + ip_addr = add_rta (header, IFA_ADDRESS, sizeof (*ip_addr));
  5466. + ip_addr->s_addr = htonl (INADDR_LOOPBACK);
  5467. +
  5468. + assert (header->nlmsg_len < sizeof (buffer));
  5469. +
  5470. + if (rtnl_do_request (rtnl_fd, header) != 0)
  5471. + die_with_error ("loopback: Failed RTM_NEWADDR");
  5472. +
  5473. + header = rtnl_setup_request (buffer, RTM_NEWLINK,
  5474. + NLM_F_ACK,
  5475. + sizeof (struct ifinfomsg));
  5476. + infomsg = NLMSG_DATA (header);
  5477. +
  5478. + infomsg->ifi_family = AF_UNSPEC;
  5479. + infomsg->ifi_type = 0;
  5480. + infomsg->ifi_index = if_loopback;
  5481. + infomsg->ifi_flags = IFF_UP;
  5482. + infomsg->ifi_change = IFF_UP;
  5483. +
  5484. + assert (header->nlmsg_len < sizeof (buffer));
  5485. +
  5486. + if (rtnl_do_request (rtnl_fd, header) != 0)
  5487. + die_with_error ("loopback: Failed RTM_NEWLINK");
  5488. +}
  5489. diff -Nuar flatpak-1.0.0.orig/bubblewrap/network.h flatpak-1.0.0/bubblewrap/network.h
  5490. --- flatpak-1.0.0.orig/bubblewrap/network.h 1970-01-01 02:00:00.000000000 +0200
  5491. +++ flatpak-1.0.0/bubblewrap/network.h 2018-02-03 21:26:06.273233339 +0300
  5492. @@ -0,0 +1,21 @@
  5493. +/* bubblewrap
  5494. + * Copyright (C) 2016 Alexander Larsson
  5495. + *
  5496. + * This program is free software; you can redistribute it and/or
  5497. + * modify it under the terms of the GNU Lesser General Public
  5498. + * License as published by the Free Software Foundation; either
  5499. + * version 2 of the License, or (at your option) any later version.
  5500. + *
  5501. + * This library is distributed in the hope that it will be useful,
  5502. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5503. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5504. + * Lesser General Public License for more details.
  5505. + *
  5506. + * You should have received a copy of the GNU Lesser General Public
  5507. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  5508. + *
  5509. + */
  5510. +
  5511. +#pragma once
  5512. +
  5513. +void loopback_setup (void);
  5514. diff -Nuar flatpak-1.0.0.orig/bubblewrap/packaging/bubblewrap.spec flatpak-1.0.0/bubblewrap/packaging/bubblewrap.spec
  5515. --- flatpak-1.0.0.orig/bubblewrap/packaging/bubblewrap.spec 1970-01-01 02:00:00.000000000 +0200
  5516. +++ flatpak-1.0.0/bubblewrap/packaging/bubblewrap.spec 2018-02-03 21:26:06.273233339 +0300
  5517. @@ -0,0 +1,49 @@
  5518. +%global commit0 66d12bb23b04e201c5846e325f0b10930ed802f8
  5519. +%global shortcommit0 %(c=%{commit0}; echo ${c:0:7})
  5520. +
  5521. +Summary: Core execution tool for unprivileged containers
  5522. +Name: bubblewrap
  5523. +Version: 0
  5524. +Release: 1%{?dist}
  5525. +#VCS: git:https://github.com/projectatomic/bubblewrap
  5526. +Source0: https://github.com/projectatomic/%{name}/archive/%{commit0}.tar.gz#/%{name}-%{shortcommit0}.tar.gz
  5527. +License: LGPLv2+
  5528. +URL: https://github.com/projectatomic/bubblewrap
  5529. +
  5530. +BuildRequires: git
  5531. +# We always run autogen.sh
  5532. +BuildRequires: autoconf automake libtool
  5533. +BuildRequires: libcap-devel
  5534. +BuildRequires: pkgconfig(libselinux)
  5535. +BuildRequires: libxslt
  5536. +BuildRequires: docbook-style-xsl
  5537. +
  5538. +%description
  5539. +Bubblewrap (/usr/bin/bwrap) is a core execution engine for unprivileged
  5540. +containers that works as a setuid binary on kernels without
  5541. +user namespaces.
  5542. +
  5543. +%prep
  5544. +%autosetup -Sgit -n %{name}-%{version}
  5545. +
  5546. +%build
  5547. +env NOCONFIGURE=1 ./autogen.sh
  5548. +%configure --disable-silent-rules --with-priv-mode=none
  5549. +
  5550. +make %{?_smp_mflags}
  5551. +
  5552. +%install
  5553. +make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p -c"
  5554. +find $RPM_BUILD_ROOT -name '*.la' -delete
  5555. +
  5556. +%files
  5557. +%license COPYING
  5558. +%doc README.md
  5559. +%{_datadir}/bash-completion/completions/bwrap
  5560. +%if (0%{?rhel} != 0 && 0%{?rhel} <= 7)
  5561. +%attr(4755,root,root) %{_bindir}/bwrap
  5562. +%else
  5563. +%{_bindir}/bwrap
  5564. +%endif
  5565. +%{_mandir}/man1/*
  5566. +
  5567. diff -Nuar flatpak-1.0.0.orig/bubblewrap/README.md flatpak-1.0.0/bubblewrap/README.md
  5568. --- flatpak-1.0.0.orig/bubblewrap/README.md 1970-01-01 02:00:00.000000000 +0200
  5569. +++ flatpak-1.0.0/bubblewrap/README.md 2018-02-03 21:26:06.272233339 +0300
  5570. @@ -0,0 +1,179 @@
  5571. +Bubblewrap
  5572. +==========
  5573. +
  5574. +Many container runtime tools like `systemd-nspawn`, `docker`,
  5575. +etc. focus on providing infrastructure for system administrators and
  5576. +orchestration tools (e.g. Kubernetes) to run containers.
  5577. +
  5578. +These tools are not suitable to give to unprivileged users, because it
  5579. +is trivial to turn such access into to a fully privileged root shell
  5580. +on the host.
  5581. +
  5582. +User namespaces
  5583. +---------------
  5584. +
  5585. +There is an effort in the Linux kernel called
  5586. +[user namespaces](https://www.google.com/search?q=user+namespaces+site%3Ahttps%3A%2F%2Flwn.net)
  5587. +which attempts to allow unprivileged users to use container features.
  5588. +While significant progress has been made, there are
  5589. +[still concerns](https://lwn.net/Articles/673597/) about it, and
  5590. +it is not available to unprivileged users in several production distributions
  5591. +such as CentOS/Red Hat Enterprise Linux 7, Debian Jessie, etc.
  5592. +
  5593. +See for example
  5594. +[CVE-2016-3135](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-3135)
  5595. +which is a local root vulnerability introduced by userns.
  5596. +[This March 2016 post](https://lkml.org/lkml/2016/3/9/555) has some
  5597. +more discussion.
  5598. +
  5599. +Bubblewrap could be viewed as setuid implementation of a *subset* of
  5600. +user namespaces. Emphasis on subset - specifically relevant to the
  5601. +above CVE, bubblewrap does not allow control over iptables.
  5602. +
  5603. +The original bubblewrap code existed before user namespaces - it inherits code from
  5604. +[xdg-app helper](https://cgit.freedesktop.org/xdg-app/xdg-app/tree/common/xdg-app-helper.c)
  5605. +which in turn distantly derives from
  5606. +[linux-user-chroot](https://git.gnome.org/browse/linux-user-chroot).
  5607. +
  5608. +Security
  5609. +--------
  5610. +
  5611. +The maintainers of this tool believe that it does not, even when used
  5612. +in combination with typical software installed on that distribution,
  5613. +allow privilege escalation. It may increase the ability of a logged
  5614. +in user to perform denial of service attacks, however.
  5615. +
  5616. +In particular, bubblewrap uses `PR_SET_NO_NEW_PRIVS` to turn off
  5617. +setuid binaries, which is the [traditional way](https://en.wikipedia.org/wiki/Chroot#Limitations) to get out of things
  5618. +like chroots.
  5619. +
  5620. +Users
  5621. +-----
  5622. +
  5623. +This program can be shared by all container tools which perform
  5624. +non-root operation, such as:
  5625. +
  5626. + - [Flatpak](http://www.flatpak.org)
  5627. + - [rpm-ostree unprivileged](https://github.com/projectatomic/rpm-ostree/pull/209)
  5628. +
  5629. +We would also like to see this be available in Kubernetes/OpenShift
  5630. +clusters. Having the ability for unprivileged users to use container
  5631. +features would make it significantly easier to do interactive
  5632. +debugging scenarios and the like.
  5633. +
  5634. +Usage
  5635. +-----
  5636. +
  5637. +bubblewrap works by creating a new, completely empty, mount
  5638. +namespace where the root is on a tmpfs that is invisible from the
  5639. +host, and will be automatically cleaned up when the last process
  5640. +exits. You can then use commandline options to construct the root
  5641. +filesystem and process environment and command to run in the
  5642. +namespace.
  5643. +
  5644. +There's a larger [demo script](./demos/bubblewrap-shell.sh) in the
  5645. +source code, but here's a trimmed down version which runs
  5646. +a new shell reusing the host's `/usr`.
  5647. +
  5648. +```
  5649. +bwrap --ro-bind /usr /usr --symlink usr/lib64 /lib64 --proc /proc --dev /dev --unshare-pid bash
  5650. +```
  5651. +
  5652. +This is an incomplete example, but useful for purposes of
  5653. +illustration. More often, rather than creating a container using the
  5654. +host's filesystem tree, you want to target a chroot. There, rather
  5655. +than creating the symlink `lib64 -> usr/lib64` in the tmpfs, you might
  5656. +have already created it in the target rootfs.
  5657. +
  5658. +Sandboxing
  5659. +----------
  5660. +
  5661. +The goal of bubblewrap is to run an application in a sandbox, where it
  5662. +has restricted access to parts of the operating system or user data
  5663. +such as the home directory.
  5664. +
  5665. +bubblewrap always creates a new mount namespace, and the user can specify
  5666. +exactly what parts of the filesystem should be visible in the sandbox.
  5667. +Any such directories you specify mounted `nodev` by default, and can be made readonly.
  5668. +
  5669. +Additionally you can use these kernel features:
  5670. +
  5671. +User namespaces ([CLONE_NEWUSER](http://linux.die.net/man/2/clone)): This hides all but the current uid and gid from the
  5672. +sandbox. You can also change what the value of uid/gid should be in the sandbox.
  5673. +
  5674. +IPC namespaces ([CLONE_NEWIPC](http://linux.die.net/man/2/clone)): The sandbox will get its own copy of all the
  5675. +different forms of IPCs, like SysV shared memory and semaphores.
  5676. +
  5677. +PID namespaces ([CLONE_NEWPID](http://linux.die.net/man/2/clone)): The sandbox will not see any processes outside the sandbox. Additionally, bubblewrap will run a trivial pid1 inside your container to handle the requirements of reaping children in the sandbox. .This avoids what is known now as the [Docker pid 1 problem](https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/).
  5678. +
  5679. +
  5680. +Network namespaces ([CLONE_NEWNET](http://linux.die.net/man/2/clone)): The sandbox will not see the network. Instead it will have its own network namespace with only a loopback device.
  5681. +
  5682. +UTS namespace ([CLONE_NEWUTS](http://linux.die.net/man/2/clone)): The sandbox will have its own hostname.
  5683. +
  5684. +Seccomp filters: You can pass in seccomp filters that limit which syscalls can be done in the sandbox. For more information, see [Seccomp](https://en.wikipedia.org/wiki/Seccomp).
  5685. +
  5686. +Related project comparison: Firejail
  5687. +------------------------------------
  5688. +
  5689. +[Firejail](https://github.com/netblue30/firejail/tree/master/src/firejail)
  5690. +is similar to Flatpak before bubblewrap was split out in that it combines
  5691. +a setuid tool with a lot of desktop-specific sandboxing features. For
  5692. +example, Firejail knows about Pulseaudio, whereas bubblewrap does not.
  5693. +
  5694. +The bubblewrap authors believe it's much easier to audit a small
  5695. +setuid program, and keep features such as Pulseaudio filtering as an
  5696. +unprivileged process, as now occurs in Flatpak.
  5697. +
  5698. +Also, @cgwalters thinks trying to
  5699. +[whitelist file paths](https://github.com/netblue30/firejail/blob/37a5a3545ef6d8d03dad8bbd888f53e13274c9e5/src/firejail/fs_whitelist.c#L176)
  5700. +is a bad idea given the myriad ways users have to manipulate paths,
  5701. +and the myriad ways in which system administrators may configure a
  5702. +system. The bubblewrap approach is to only retain a few specific
  5703. +Linux capabilities such as `CAP_SYS_ADMIN`, but to always access the
  5704. +filesystem as the invoking uid. This entirely closes
  5705. +[TOCTTOU attacks](https://cwe.mitre.org/data/definitions/367.html) and
  5706. +such.
  5707. +
  5708. +Related project comparison: Sandstorm.io
  5709. +----------------------------------------
  5710. +
  5711. +[Sandstorm.io](https://sandstorm.io/) requries unprivileged user
  5712. +namespaces to set up its sandbox, though it could easily be adapted
  5713. +to operate in a setuid mode as well. @cgwalters believes their code is
  5714. +fairly good, but it could still make sense to unify on bubblewrap.
  5715. +However, @kentonv (of Sandstorm) feels that while this makes sense
  5716. +in principle, the switching cost outweighs the practical benefits for
  5717. +now. This decision could be re-evaluated in the future, but it is not
  5718. +being actively pursued today.
  5719. +
  5720. +Related project comparison: runc/binctr
  5721. +----------------------------------------
  5722. +
  5723. +[runC](https://github.com/opencontainers/runc) is currently working on
  5724. +supporting [rootless containers](https://github.com/opencontainers/runc/pull/774),
  5725. +without needing `setuid` or any other privileges during installation of
  5726. +runC (using unprivileged user namespaces rather than `setuid`),
  5727. +creation, and management of containers. However, the standard mode of
  5728. +using runC is similar to [systemd nspawn](https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html)
  5729. +in that it is tooling intended to be invoked by root.
  5730. +
  5731. +The bubblewrap authors believe that runc and systemd-nspawn are not
  5732. +designed to be made setuid, and are distant from supporting such a mode.
  5733. +However with rootless containers, runC will be able to fulfill certain usecases
  5734. +that bubblewrap supports (with the added benefit of being a standardised and
  5735. +complete OCI runtime).
  5736. +
  5737. +[binctr](https://github.com/jfrazelle/binctr) is just a wrapper for
  5738. +runC, so inherits all of its design tradeoffs.
  5739. +
  5740. +Whats with the name ?!
  5741. +----------------------
  5742. +
  5743. +The name bubblewrap was chosen to convey that this
  5744. +tool runs as the parent of the application (so wraps it in some sense) and creates
  5745. +a protective layer (the sandbox) around it.
  5746. +
  5747. +![](bubblewrap.jpg)
  5748. +
  5749. +(Bubblewrap cat by [dancing_stupidity](https://www.flickr.com/photos/27549668@N03/))
  5750. diff -Nuar flatpak-1.0.0.orig/bubblewrap/.redhat-ci.yml flatpak-1.0.0/bubblewrap/.redhat-ci.yml
  5751. --- flatpak-1.0.0.orig/bubblewrap/.redhat-ci.yml 1970-01-01 02:00:00.000000000 +0200
  5752. +++ flatpak-1.0.0/bubblewrap/.redhat-ci.yml 2018-02-03 21:26:06.271233339 +0300
  5753. @@ -0,0 +1,25 @@
  5754. +context: centos7
  5755. +required: true
  5756. +
  5757. +branches:
  5758. + - master
  5759. + - auto
  5760. + - try
  5761. +
  5762. +host:
  5763. + distro: centos/7/atomic
  5764. +
  5765. +tests:
  5766. + - env BWRAP_SUID=true ./ci/redhat-ci.sh centos:7
  5767. +
  5768. +timeout: 30m
  5769. +
  5770. +---
  5771. +
  5772. +inherit: true
  5773. +
  5774. +context: f25-asan-ubsan
  5775. +required: true
  5776. +
  5777. +tests:
  5778. + - env CFLAGS='-g -Og -fsanitize=undefined -fsanitize=address' ./ci/redhat-ci.sh fedora:25
  5779. diff -Nuar flatpak-1.0.0.orig/bubblewrap/tests/test-run.sh flatpak-1.0.0/bubblewrap/tests/test-run.sh
  5780. --- flatpak-1.0.0.orig/bubblewrap/tests/test-run.sh 1970-01-01 02:00:00.000000000 +0200
  5781. +++ flatpak-1.0.0/bubblewrap/tests/test-run.sh 2018-02-03 21:26:06.274233339 +0300
  5782. @@ -0,0 +1,132 @@
  5783. +#!/bin/bash
  5784. +
  5785. +set -xeuo pipefail
  5786. +
  5787. +srcd=$(cd $(dirname $0) && pwd)
  5788. +bn=$(basename $0)
  5789. +tempdir=$(mktemp -d /var/tmp/tap-test.XXXXXX)
  5790. +touch ${tempdir}/.testtmp
  5791. +function cleanup () {
  5792. + if test -n "${TEST_SKIP_CLEANUP:-}"; then
  5793. + echo "Skipping cleanup of ${test_tmpdir}"
  5794. + else if test -f ${tempdir}/.test; then
  5795. + rm "${tempdir}" -rf
  5796. + fi
  5797. + fi
  5798. +}
  5799. +trap cleanup EXIT
  5800. +cd ${tempdir}
  5801. +
  5802. +: "${BWRAP:=bwrap}"
  5803. +
  5804. +skip () {
  5805. + echo $@ 1>&2; exit 77
  5806. +}
  5807. +
  5808. +assert_not_reached () {
  5809. + echo $@ 1>&2; exit 1
  5810. +}
  5811. +
  5812. +assert_file_has_content () {
  5813. + if ! grep -q -e "$2" "$1"; then
  5814. + echo 1>&2 "File '$1' doesn't match regexp '$2'"; exit 1
  5815. + fi
  5816. +}
  5817. +
  5818. +FUSE_DIR=
  5819. +for mp in $(cat /proc/self/mounts | grep " fuse[. ]" | grep user_id=$(id -u) | awk '{print $2}'); do
  5820. + if test -d $mp; then
  5821. + echo Using $mp as test fuse mount
  5822. + FUSE_DIR=$mp
  5823. + break
  5824. + fi
  5825. +done
  5826. +
  5827. +# This is supposed to be an otherwise readable file in an unreadable (by the user) dir
  5828. +UNREADABLE=/root/.bashrc
  5829. +if test -x `dirname $UNREADABLE`; then
  5830. + UNREADABLE=
  5831. +fi
  5832. +
  5833. +# Default arg, bind whole host fs to /, tmpfs on /tmp
  5834. +RUN="${BWRAP} --bind / / --tmpfs /tmp"
  5835. +
  5836. +if ! $RUN true; then
  5837. + skip Seems like bwrap is not working at all. Maybe setuid is not working
  5838. +fi
  5839. +
  5840. +# Test help
  5841. +${BWRAP} --help > help.txt
  5842. +assert_file_has_content help.txt "usage: ${BWRAP}"
  5843. +
  5844. +for ALT in "" "--unshare-user-try" "--unshare-pid" "--unshare-user-try --unshare-pid"; do
  5845. + # Test fuse fs as bind source
  5846. + if [ x$FUSE_DIR != x ]; then
  5847. + $RUN $ALT --proc /proc --dev /dev --bind $FUSE_DIR /tmp/foo true
  5848. + fi
  5849. + # no --dev => no devpts => no map_root workaround
  5850. + $RUN $ALT --proc /proc true
  5851. + # No network
  5852. + $RUN $ALT --unshare-net --proc /proc --dev /dev true
  5853. + # Unreadable file
  5854. + echo -n "expect EPERM: "
  5855. + if $RUN $ALT --unshare-net --proc /proc --bind /etc/shadow /tmp/foo cat /etc/shadow; then
  5856. + assert_not_reached Could read /etc/shadow
  5857. + fi
  5858. + # Unreadable dir
  5859. + if [ x$UNREADABLE != x ]; then
  5860. + echo -n "expect EPERM: "
  5861. + if $RUN $ALT --unshare-net --proc /proc --dev /dev --bind $UNREADABLE /tmp/foo cat /tmp/foo ; then
  5862. + assert_not_reached Could read $UNREADABLE
  5863. + fi
  5864. + fi
  5865. +
  5866. + # bind dest in symlink (https://github.com/projectatomic/bubblewrap/pull/119)
  5867. + $RUN $ALT --dir /tmp/dir --symlink dir /tmp/link --bind /etc /tmp/link true
  5868. +done
  5869. +
  5870. +# Test --die-with-parent
  5871. +
  5872. +cat >lockf-n.py <<EOF
  5873. +#!/usr/bin/env python
  5874. +import struct,fcntl,sys
  5875. +path = sys.argv[1]
  5876. +if sys.argv[2] == 'wait':
  5877. + locktype = fcntl.F_SETLKW
  5878. +else:
  5879. + locktype = fcntl.F_SETLK
  5880. +lockdata = struct.pack("hhllhh", fcntl.F_WRLCK, 0, 0, 0, 0, 0)
  5881. +fd=open(sys.argv[1], 'a')
  5882. +try:
  5883. + fcntl.fcntl(fd.fileno(), locktype, lockdata)
  5884. +except IOError as e:
  5885. + sys.exit(1)
  5886. +sys.exit(0)
  5887. +EOF
  5888. +chmod a+x lockf-n.py
  5889. +touch lock
  5890. +
  5891. +for die_with_parent_argv in "--die-with-parent" "--die-with-parent --unshare-pid"; do
  5892. + /bin/bash -c "$RUN ${die_with_parent_argv} --lock-file $(pwd)/lock sleep 1h && true" &
  5893. + childshellpid=$!
  5894. +
  5895. + # Wait for lock to be taken (yes hacky)
  5896. + for x in $(seq 10); do
  5897. + if ./lockf-n.py ./lock nowait; then
  5898. + sleep 1
  5899. + else
  5900. + break
  5901. + fi
  5902. + done
  5903. + if ./lockf-n.py ./lock nowait; then
  5904. + assert_not_reached "timed out waiting for lock"
  5905. + fi
  5906. +
  5907. + # Kill the shell, which should kill bwrap (and the sleep)
  5908. + kill -9 ${childshellpid}
  5909. + # Lock file should be unlocked
  5910. + ./lockf-n.py ./lock wait
  5911. + echo "ok die with parent ${die_with_parent_argv}"
  5912. +done
  5913. +
  5914. +echo OK
  5915. diff -Nuar flatpak-1.0.0.orig/bubblewrap/.travis.yml flatpak-1.0.0/bubblewrap/.travis.yml
  5916. --- flatpak-1.0.0.orig/bubblewrap/.travis.yml 1970-01-01 02:00:00.000000000 +0200
  5917. +++ flatpak-1.0.0/bubblewrap/.travis.yml 2018-02-03 21:26:06.271233339 +0300
  5918. @@ -0,0 +1,25 @@
  5919. +language: c
  5920. +dist: trusty
  5921. +addons:
  5922. + apt:
  5923. + packages:
  5924. + - automake
  5925. + - autotools-dev
  5926. + - libcap-dev
  5927. +script:
  5928. + - env NOCONFIGURE=1 ./autogen.sh
  5929. + - mkdir build
  5930. + - cd build && ../configure
  5931. + - make -j 2
  5932. + - make check
  5933. +
  5934. +notifications:
  5935. + # This is Colin's instance of Homu, in the future
  5936. + # we'll move this to a production cluster.
  5937. + webhooks: http://escher.verbum.org:54856/travis
  5938. + email: false
  5939. +
  5940. +branches:
  5941. + only:
  5942. + - auto
  5943. +
  5944. diff -Nuar flatpak-1.0.0.orig/bubblewrap/uncrustify.cfg flatpak-1.0.0/bubblewrap/uncrustify.cfg
  5945. --- flatpak-1.0.0.orig/bubblewrap/uncrustify.cfg 1970-01-01 02:00:00.000000000 +0200
  5946. +++ flatpak-1.0.0/bubblewrap/uncrustify.cfg 2018-02-03 21:26:06.274233339 +0300
  5947. @@ -0,0 +1,136 @@
  5948. +newlines lf
  5949. +
  5950. +input_tab_size 8
  5951. +output_tab_size 8
  5952. +
  5953. +string_escape_char 92
  5954. +string_escape_char2 0
  5955. +
  5956. +# indenting
  5957. +indent_columns 2
  5958. +indent_with_tabs 0
  5959. +indent_align_string True
  5960. +indent_brace 2
  5961. +indent_braces false
  5962. +indent_braces_no_func True
  5963. +indent_func_call_param false
  5964. +indent_func_def_param false
  5965. +indent_func_proto_param false
  5966. +indent_switch_case 0
  5967. +indent_case_brace 2
  5968. +indent_paren_close 1
  5969. +
  5970. +# spacing
  5971. +sp_arith Add
  5972. +sp_assign Add
  5973. +sp_enum_assign Add
  5974. +sp_bool Add
  5975. +sp_compare Add
  5976. +sp_inside_paren Remove
  5977. +sp_inside_fparens Remove
  5978. +sp_func_def_paren Force
  5979. +sp_func_proto_paren Force
  5980. +sp_paren_paren Remove
  5981. +sp_balance_nested_parens False
  5982. +sp_paren_brace Remove
  5983. +sp_before_square Remove
  5984. +sp_before_squares Remove
  5985. +sp_inside_square Remove
  5986. +sp_before_ptr_star Add
  5987. +sp_between_ptr_star Remove
  5988. +sp_after_comma Add
  5989. +sp_before_comma Remove
  5990. +sp_after_cast Add
  5991. +sp_sizeof_paren Add
  5992. +sp_not Remove
  5993. +sp_inv Remove
  5994. +sp_addr Remove
  5995. +sp_member Remove
  5996. +sp_deref Remove
  5997. +sp_sign Remove
  5998. +sp_incdec Remove
  5999. +sp_attribute_paren remove
  6000. +sp_macro Force
  6001. +sp_func_call_paren Force
  6002. +sp_func_call_user_paren Remove
  6003. +set func_call_user _ N_ C_ g_autoptr g_auto
  6004. +sp_brace_typedef add
  6005. +sp_cond_colon add
  6006. +sp_cond_question add
  6007. +sp_defined_paren remove
  6008. +
  6009. +# alignment
  6010. +align_keep_tabs False
  6011. +align_with_tabs False
  6012. +align_on_tabstop False
  6013. +align_number_left True
  6014. +align_func_params True
  6015. +align_var_def_span 0
  6016. +align_var_def_amp_style 1
  6017. +align_var_def_colon true
  6018. +align_enum_equ_span 0
  6019. +align_var_struct_span 2
  6020. +align_var_def_star_style 2
  6021. +align_var_def_amp_style 2
  6022. +align_typedef_span 2
  6023. +align_typedef_func 0
  6024. +align_typedef_star_style 2
  6025. +align_typedef_amp_style 2
  6026. +
  6027. +# newlines
  6028. +nl_assign_leave_one_liners True
  6029. +nl_enum_leave_one_liners False
  6030. +nl_func_leave_one_liners False
  6031. +nl_if_leave_one_liners False
  6032. +nl_end_of_file Add
  6033. +nl_assign_brace Remove
  6034. +nl_func_var_def_blk 1
  6035. +nl_fcall_brace Add
  6036. +nl_enum_brace Remove
  6037. +nl_struct_brace Force
  6038. +nl_union_brace Force
  6039. +nl_if_brace Force
  6040. +nl_brace_else Force
  6041. +nl_elseif_brace Force
  6042. +nl_else_brace Add
  6043. +nl_for_brace Force
  6044. +nl_while_brace Force
  6045. +nl_do_brace Force
  6046. +nl_brace_while Force
  6047. +nl_switch_brace Force
  6048. +nl_before_case True
  6049. +nl_after_case False
  6050. +nl_func_type_name Force
  6051. +nl_func_proto_type_name Remove
  6052. +nl_func_paren Remove
  6053. +nl_func_decl_start Remove
  6054. +nl_func_decl_args Force
  6055. +nl_func_decl_end Remove
  6056. +nl_fdef_brace Force
  6057. +nl_after_return False
  6058. +nl_define_macro False
  6059. +nl_create_if_one_liner False
  6060. +nl_create_for_one_liner False
  6061. +nl_create_while_one_liner False
  6062. +nl_after_semicolon True
  6063. +nl_multi_line_cond true
  6064. +
  6065. +# mod
  6066. +# I'd like these to be remove, but that removes brackets in if { if { foo } }, which i dislike
  6067. +# Not clear what to do about that...
  6068. +mod_full_brace_for Remove
  6069. +mod_full_brace_if Remove
  6070. +mod_full_brace_if_chain True
  6071. +mod_full_brace_while Remove
  6072. +mod_full_brace_do Remove
  6073. +mod_full_brace_nl 3
  6074. +mod_paren_on_return Remove
  6075. +
  6076. +# line splitting
  6077. +#code_width = 78
  6078. +ls_for_split_full True
  6079. +ls_func_split_full True
  6080. +
  6081. +# positioning
  6082. +pos_bool Trail
  6083. +pos_conditional Trail
  6084. diff -Nuar flatpak-1.0.0.orig/bubblewrap/uncrustify.sh flatpak-1.0.0/bubblewrap/uncrustify.sh
  6085. --- flatpak-1.0.0.orig/bubblewrap/uncrustify.sh 1970-01-01 02:00:00.000000000 +0200
  6086. +++ flatpak-1.0.0/bubblewrap/uncrustify.sh 2018-02-03 21:26:06.274233339 +0300
  6087. @@ -0,0 +1,2 @@
  6088. +#!/bin/sh
  6089. +uncrustify -c uncrustify.cfg --no-backup `git ls-tree --name-only -r HEAD | grep \\\.[ch]$`
  6090. diff -Nuar flatpak-1.0.0.orig/bubblewrap/utils.c flatpak-1.0.0/bubblewrap/utils.c
  6091. --- flatpak-1.0.0.orig/bubblewrap/utils.c 1970-01-01 02:00:00.000000000 +0200
  6092. +++ flatpak-1.0.0/bubblewrap/utils.c 2018-02-03 21:26:06.274233339 +0300
  6093. @@ -0,0 +1,709 @@
  6094. +/* bubblewrap
  6095. + * Copyright (C) 2016 Alexander Larsson
  6096. + *
  6097. + * This program is free software; you can redistribute it and/or
  6098. + * modify it under the terms of the GNU Lesser General Public
  6099. + * License as published by the Free Software Foundation; either
  6100. + * version 2 of the License, or (at your option) any later version.
  6101. + *
  6102. + * This library is distributed in the hope that it will be useful,
  6103. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6104. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6105. + * Lesser General Public License for more details.
  6106. + *
  6107. + * You should have received a copy of the GNU Lesser General Public
  6108. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  6109. + *
  6110. + */
  6111. +#include "config.h"
  6112. +
  6113. +#include "utils.h"
  6114. +#include <sys/syscall.h>
  6115. +#ifdef HAVE_SELINUX
  6116. +#include <selinux/selinux.h>
  6117. +#endif
  6118. +
  6119. +void
  6120. +die_with_error (const char *format, ...)
  6121. +{
  6122. + va_list args;
  6123. + int errsv;
  6124. +
  6125. + errsv = errno;
  6126. +
  6127. + va_start (args, format);
  6128. + vfprintf (stderr, format, args);
  6129. + va_end (args);
  6130. +
  6131. + fprintf (stderr, ": %s\n", strerror (errsv));
  6132. +
  6133. + exit (1);
  6134. +}
  6135. +
  6136. +void
  6137. +die (const char *format, ...)
  6138. +{
  6139. + va_list args;
  6140. +
  6141. + va_start (args, format);
  6142. + vfprintf (stderr, format, args);
  6143. + va_end (args);
  6144. +
  6145. + fprintf (stderr, "\n");
  6146. +
  6147. + exit (1);
  6148. +}
  6149. +
  6150. +void
  6151. +die_unless_label_valid (const char *label)
  6152. +{
  6153. +#ifdef HAVE_SELINUX
  6154. + if (is_selinux_enabled () == 1)
  6155. + {
  6156. + if (security_check_context ((security_context_t) label) < 0)
  6157. + die_with_error ("invalid label %s", label);
  6158. + return;
  6159. + }
  6160. +#endif
  6161. + die ("labeling not supported on this system");
  6162. +}
  6163. +
  6164. +void
  6165. +die_oom (void)
  6166. +{
  6167. + puts ("Out of memory");
  6168. + exit (1);
  6169. +}
  6170. +
  6171. +void *
  6172. +xmalloc (size_t size)
  6173. +{
  6174. + void *res = malloc (size);
  6175. +
  6176. + if (res == NULL)
  6177. + die_oom ();
  6178. + return res;
  6179. +}
  6180. +
  6181. +void *
  6182. +xcalloc (size_t size)
  6183. +{
  6184. + void *res = calloc (1, size);
  6185. +
  6186. + if (res == NULL)
  6187. + die_oom ();
  6188. + return res;
  6189. +}
  6190. +
  6191. +void *
  6192. +xrealloc (void *ptr, size_t size)
  6193. +{
  6194. + void *res = realloc (ptr, size);
  6195. +
  6196. + if (size != 0 && res == NULL)
  6197. + die_oom ();
  6198. + return res;
  6199. +}
  6200. +
  6201. +char *
  6202. +xstrdup (const char *str)
  6203. +{
  6204. + char *res;
  6205. +
  6206. + assert (str != NULL);
  6207. +
  6208. + res = strdup (str);
  6209. + if (res == NULL)
  6210. + die_oom ();
  6211. +
  6212. + return res;
  6213. +}
  6214. +
  6215. +void
  6216. +strfreev (char **str_array)
  6217. +{
  6218. + if (str_array)
  6219. + {
  6220. + int i;
  6221. +
  6222. + for (i = 0; str_array[i] != NULL; i++)
  6223. + free (str_array[i]);
  6224. +
  6225. + free (str_array);
  6226. + }
  6227. +}
  6228. +
  6229. +/* Compares if str has a specific path prefix. This differs
  6230. + from a regular prefix in two ways. First of all there may
  6231. + be multiple slashes separating the path elements, and
  6232. + secondly, if a prefix is matched that has to be en entire
  6233. + path element. For instance /a/prefix matches /a/prefix/foo/bar,
  6234. + but not /a/prefixfoo/bar. */
  6235. +bool
  6236. +has_path_prefix (const char *str,
  6237. + const char *prefix)
  6238. +{
  6239. + while (TRUE)
  6240. + {
  6241. + /* Skip consecutive slashes to reach next path
  6242. + element */
  6243. + while (*str == '/')
  6244. + str++;
  6245. + while (*prefix == '/')
  6246. + prefix++;
  6247. +
  6248. + /* No more prefix path elements? Done! */
  6249. + if (*prefix == 0)
  6250. + return TRUE;
  6251. +
  6252. + /* Compare path element */
  6253. + while (*prefix != 0 && *prefix != '/')
  6254. + {
  6255. + if (*str != *prefix)
  6256. + return FALSE;
  6257. + str++;
  6258. + prefix++;
  6259. + }
  6260. +
  6261. + /* Matched prefix path element,
  6262. + must be entire str path element */
  6263. + if (*str != '/' && *str != 0)
  6264. + return FALSE;
  6265. + }
  6266. +}
  6267. +
  6268. +bool
  6269. +path_equal (const char *path1,
  6270. + const char *path2)
  6271. +{
  6272. + while (TRUE)
  6273. + {
  6274. + /* Skip consecutive slashes to reach next path
  6275. + element */
  6276. + while (*path1 == '/')
  6277. + path1++;
  6278. + while (*path2 == '/')
  6279. + path2++;
  6280. +
  6281. + /* No more prefix path elements? Done! */
  6282. + if (*path1 == 0 || *path2 == 0)
  6283. + return *path1 == 0 && *path2 == 0;
  6284. +
  6285. + /* Compare path element */
  6286. + while (*path1 != 0 && *path1 != '/')
  6287. + {
  6288. + if (*path1 != *path2)
  6289. + return FALSE;
  6290. + path1++;
  6291. + path2++;
  6292. + }
  6293. +
  6294. + /* Matched path1 path element, must be entire path element */
  6295. + if (*path2 != '/' && *path2 != 0)
  6296. + return FALSE;
  6297. + }
  6298. +}
  6299. +
  6300. +
  6301. +bool
  6302. +has_prefix (const char *str,
  6303. + const char *prefix)
  6304. +{
  6305. + return strncmp (str, prefix, strlen (prefix)) == 0;
  6306. +}
  6307. +
  6308. +void
  6309. +xsetenv (const char *name, const char *value, int overwrite)
  6310. +{
  6311. + if (setenv (name, value, overwrite))
  6312. + die ("setenv failed");
  6313. +}
  6314. +
  6315. +void
  6316. +xunsetenv (const char *name)
  6317. +{
  6318. + if (unsetenv (name))
  6319. + die ("unsetenv failed");
  6320. +}
  6321. +
  6322. +char *
  6323. +strconcat (const char *s1,
  6324. + const char *s2)
  6325. +{
  6326. + size_t len = 0;
  6327. + char *res;
  6328. +
  6329. + if (s1)
  6330. + len += strlen (s1);
  6331. + if (s2)
  6332. + len += strlen (s2);
  6333. +
  6334. + res = xmalloc (len + 1);
  6335. + *res = 0;
  6336. + if (s1)
  6337. + strcat (res, s1);
  6338. + if (s2)
  6339. + strcat (res, s2);
  6340. +
  6341. + return res;
  6342. +}
  6343. +
  6344. +char *
  6345. +strconcat3 (const char *s1,
  6346. + const char *s2,
  6347. + const char *s3)
  6348. +{
  6349. + size_t len = 0;
  6350. + char *res;
  6351. +
  6352. + if (s1)
  6353. + len += strlen (s1);
  6354. + if (s2)
  6355. + len += strlen (s2);
  6356. + if (s3)
  6357. + len += strlen (s3);
  6358. +
  6359. + res = xmalloc (len + 1);
  6360. + *res = 0;
  6361. + if (s1)
  6362. + strcat (res, s1);
  6363. + if (s2)
  6364. + strcat (res, s2);
  6365. + if (s3)
  6366. + strcat (res, s3);
  6367. +
  6368. + return res;
  6369. +}
  6370. +
  6371. +char *
  6372. +xasprintf (const char *format,
  6373. + ...)
  6374. +{
  6375. + char *buffer = NULL;
  6376. + va_list args;
  6377. +
  6378. + va_start (args, format);
  6379. + if (vasprintf (&buffer, format, args) == -1)
  6380. + die_oom ();
  6381. + va_end (args);
  6382. +
  6383. + return buffer;
  6384. +}
  6385. +
  6386. +int
  6387. +fdwalk (int proc_fd, int (*cb)(void *data,
  6388. + int fd), void *data)
  6389. +{
  6390. + int open_max;
  6391. + int fd;
  6392. + int dfd;
  6393. + int res = 0;
  6394. + DIR *d;
  6395. +
  6396. + dfd = openat (proc_fd, "self/fd", O_DIRECTORY | O_RDONLY | O_NONBLOCK | O_CLOEXEC | O_NOCTTY);
  6397. + if (dfd == -1)
  6398. + return res;
  6399. +
  6400. + if ((d = fdopendir (dfd)))
  6401. + {
  6402. + struct dirent *de;
  6403. +
  6404. + while ((de = readdir (d)))
  6405. + {
  6406. + long l;
  6407. + char *e = NULL;
  6408. +
  6409. + if (de->d_name[0] == '.')
  6410. + continue;
  6411. +
  6412. + errno = 0;
  6413. + l = strtol (de->d_name, &e, 10);
  6414. + if (errno != 0 || !e || *e)
  6415. + continue;
  6416. +
  6417. + fd = (int) l;
  6418. +
  6419. + if ((long) fd != l)
  6420. + continue;
  6421. +
  6422. + if (fd == dirfd (d))
  6423. + continue;
  6424. +
  6425. + if ((res = cb (data, fd)) != 0)
  6426. + break;
  6427. + }
  6428. +
  6429. + closedir (d);
  6430. + return res;
  6431. + }
  6432. +
  6433. + open_max = sysconf (_SC_OPEN_MAX);
  6434. +
  6435. + for (fd = 0; fd < open_max; fd++)
  6436. + if ((res = cb (data, fd)) != 0)
  6437. + break;
  6438. +
  6439. + return res;
  6440. +}
  6441. +
  6442. +/* Sets errno on error (!= 0), ENOSPC on short write */
  6443. +int
  6444. +write_to_fd (int fd,
  6445. + const char *content,
  6446. + ssize_t len)
  6447. +{
  6448. + ssize_t res;
  6449. +
  6450. + while (len > 0)
  6451. + {
  6452. + res = write (fd, content, len);
  6453. + if (res < 0 && errno == EINTR)
  6454. + continue;
  6455. + if (res <= 0)
  6456. + {
  6457. + if (res == 0) /* Unexpected short write, should not happen when writing to a file */
  6458. + errno = ENOSPC;
  6459. + return -1;
  6460. + }
  6461. + len -= res;
  6462. + content += res;
  6463. + }
  6464. +
  6465. + return 0;
  6466. +}
  6467. +
  6468. +/* Sets errno on error (!= 0), ENOSPC on short write */
  6469. +int
  6470. +write_file_at (int dirfd,
  6471. + const char *path,
  6472. + const char *content)
  6473. +{
  6474. + int fd;
  6475. + bool res;
  6476. + int errsv;
  6477. +
  6478. + fd = openat (dirfd, path, O_RDWR | O_CLOEXEC, 0);
  6479. + if (fd == -1)
  6480. + return -1;
  6481. +
  6482. + res = 0;
  6483. + if (content)
  6484. + res = write_to_fd (fd, content, strlen (content));
  6485. +
  6486. + errsv = errno;
  6487. + close (fd);
  6488. + errno = errsv;
  6489. +
  6490. + return res;
  6491. +}
  6492. +
  6493. +/* Sets errno on error (!= 0), ENOSPC on short write */
  6494. +int
  6495. +create_file (const char *path,
  6496. + mode_t mode,
  6497. + const char *content)
  6498. +{
  6499. + int fd;
  6500. + int res;
  6501. + int errsv;
  6502. +
  6503. + fd = creat (path, mode);
  6504. + if (fd == -1)
  6505. + return -1;
  6506. +
  6507. + res = 0;
  6508. + if (content)
  6509. + res = write_to_fd (fd, content, strlen (content));
  6510. +
  6511. + errsv = errno;
  6512. + close (fd);
  6513. + errno = errsv;
  6514. +
  6515. + return res;
  6516. +}
  6517. +
  6518. +int
  6519. +ensure_file (const char *path,
  6520. + mode_t mode)
  6521. +{
  6522. + struct stat buf;
  6523. +
  6524. + /* We check this ahead of time, otherwise
  6525. + the create file will fail in the read-only
  6526. + case with EROFD instead of EEXIST */
  6527. + if (stat (path, &buf) == 0 &&
  6528. + S_ISREG (buf.st_mode))
  6529. + return 0;
  6530. +
  6531. + if (create_file (path, mode, NULL) != 0 && errno != EEXIST)
  6532. + return -1;
  6533. +
  6534. + return 0;
  6535. +}
  6536. +
  6537. +
  6538. +#define BUFSIZE 8192
  6539. +/* Sets errno on error (!= 0), ENOSPC on short write */
  6540. +int
  6541. +copy_file_data (int sfd,
  6542. + int dfd)
  6543. +{
  6544. + char buffer[BUFSIZE];
  6545. + ssize_t bytes_read;
  6546. +
  6547. + while (TRUE)
  6548. + {
  6549. + bytes_read = read (sfd, buffer, BUFSIZE);
  6550. + if (bytes_read == -1)
  6551. + {
  6552. + if (errno == EINTR)
  6553. + continue;
  6554. +
  6555. + return -1;
  6556. + }
  6557. +
  6558. + if (bytes_read == 0)
  6559. + break;
  6560. +
  6561. + if (write_to_fd (dfd, buffer, bytes_read) != 0)
  6562. + return -1;
  6563. + }
  6564. +
  6565. + return 0;
  6566. +}
  6567. +
  6568. +/* Sets errno on error (!= 0), ENOSPC on short write */
  6569. +int
  6570. +copy_file (const char *src_path,
  6571. + const char *dst_path,
  6572. + mode_t mode)
  6573. +{
  6574. + int sfd;
  6575. + int dfd;
  6576. + int res;
  6577. + int errsv;
  6578. +
  6579. + sfd = open (src_path, O_CLOEXEC | O_RDONLY);
  6580. + if (sfd == -1)
  6581. + return -1;
  6582. +
  6583. + dfd = creat (dst_path, mode);
  6584. + if (dfd == -1)
  6585. + {
  6586. + errsv = errno;
  6587. + close (sfd);
  6588. + errno = errsv;
  6589. + return -1;
  6590. + }
  6591. +
  6592. + res = copy_file_data (sfd, dfd);
  6593. +
  6594. + errsv = errno;
  6595. + close (sfd);
  6596. + close (dfd);
  6597. + errno = errsv;
  6598. +
  6599. + return res;
  6600. +}
  6601. +
  6602. +/* Sets errno on error (== NULL),
  6603. + * Always ensures terminating zero */
  6604. +char *
  6605. +load_file_data (int fd,
  6606. + size_t *size)
  6607. +{
  6608. + cleanup_free char *data = NULL;
  6609. + ssize_t data_read;
  6610. + ssize_t data_len;
  6611. + ssize_t res;
  6612. + int errsv;
  6613. +
  6614. + data_read = 0;
  6615. + data_len = 4080;
  6616. + data = xmalloc (data_len);
  6617. +
  6618. + do
  6619. + {
  6620. + if (data_len == data_read + 1)
  6621. + {
  6622. + data_len *= 2;
  6623. + data = xrealloc (data, data_len);
  6624. + }
  6625. +
  6626. + do
  6627. + res = read (fd, data + data_read, data_len - data_read - 1);
  6628. + while (res < 0 && errno == EINTR);
  6629. +
  6630. + if (res < 0)
  6631. + {
  6632. + errsv = errno;
  6633. + close (fd);
  6634. + errno = errsv;
  6635. + return NULL;
  6636. + }
  6637. +
  6638. + data_read += res;
  6639. + }
  6640. + while (res > 0);
  6641. +
  6642. + data[data_read] = 0;
  6643. +
  6644. + if (size)
  6645. + *size = (size_t) data_read;
  6646. +
  6647. + return steal_pointer (&data);
  6648. +}
  6649. +
  6650. +/* Sets errno on error (== NULL),
  6651. + * Always ensures terminating zero */
  6652. +char *
  6653. +load_file_at (int dirfd,
  6654. + const char *path)
  6655. +{
  6656. + int fd;
  6657. + char *data;
  6658. + int errsv;
  6659. +
  6660. + fd = openat (dirfd, path, O_CLOEXEC | O_RDONLY);
  6661. + if (fd == -1)
  6662. + return NULL;
  6663. +
  6664. + data = load_file_data (fd, NULL);
  6665. +
  6666. + errsv = errno;
  6667. + close (fd);
  6668. + errno = errsv;
  6669. +
  6670. + return data;
  6671. +}
  6672. +
  6673. +/* Sets errno on error (< 0) */
  6674. +int
  6675. +get_file_mode (const char *pathname)
  6676. +{
  6677. + struct stat buf;
  6678. +
  6679. + if (stat (pathname, &buf) != 0)
  6680. + return -1;
  6681. +
  6682. + return buf.st_mode & S_IFMT;
  6683. +}
  6684. +
  6685. +/* Sets errno on error (!= 0) */
  6686. +int
  6687. +mkdir_with_parents (const char *pathname,
  6688. + int mode,
  6689. + bool create_last)
  6690. +{
  6691. + cleanup_free char *fn = NULL;
  6692. + char *p;
  6693. + struct stat buf;
  6694. +
  6695. + if (pathname == NULL || *pathname == '\0')
  6696. + {
  6697. + errno = EINVAL;
  6698. + return -1;
  6699. + }
  6700. +
  6701. + fn = xstrdup (pathname);
  6702. +
  6703. + p = fn;
  6704. + while (*p == '/')
  6705. + p++;
  6706. +
  6707. + do
  6708. + {
  6709. + while (*p && *p != '/')
  6710. + p++;
  6711. +
  6712. + if (!*p)
  6713. + p = NULL;
  6714. + else
  6715. + *p = '\0';
  6716. +
  6717. + if (!create_last && p == NULL)
  6718. + break;
  6719. +
  6720. + if (stat (fn, &buf) != 0)
  6721. + {
  6722. + if (mkdir (fn, mode) == -1 && errno != EEXIST)
  6723. + return -1;
  6724. + }
  6725. + else if (!S_ISDIR (buf.st_mode))
  6726. + {
  6727. + errno = ENOTDIR;
  6728. + return -1;
  6729. + }
  6730. +
  6731. + if (p)
  6732. + {
  6733. + *p++ = '/';
  6734. + while (*p && *p == '/')
  6735. + p++;
  6736. + }
  6737. + }
  6738. + while (p);
  6739. +
  6740. + return 0;
  6741. +}
  6742. +
  6743. +int
  6744. +raw_clone (unsigned long flags,
  6745. + void *child_stack)
  6746. +{
  6747. +#if defined(__s390__) || defined(__CRIS__)
  6748. + /* On s390 and cris the order of the first and second arguments
  6749. + * of the raw clone() system call is reversed. */
  6750. + return (int) syscall (__NR_clone, child_stack, flags);
  6751. +#else
  6752. + return (int) syscall (__NR_clone, flags, child_stack);
  6753. +#endif
  6754. +}
  6755. +
  6756. +int
  6757. +pivot_root (const char * new_root, const char * put_old)
  6758. +{
  6759. +#ifdef __NR_pivot_root
  6760. + return syscall (__NR_pivot_root, new_root, put_old);
  6761. +#else
  6762. + errno = ENOSYS;
  6763. + return -1;
  6764. +#endif
  6765. +}
  6766. +
  6767. +char *
  6768. +label_mount (const char *opt, const char *mount_label)
  6769. +{
  6770. +#ifdef HAVE_SELINUX
  6771. + if (mount_label)
  6772. + {
  6773. + if (opt)
  6774. + return xasprintf ("%s,context=\"%s\"", opt, mount_label);
  6775. + else
  6776. + return xasprintf ("context=\"%s\"", mount_label);
  6777. + }
  6778. +#endif
  6779. + if (opt)
  6780. + return xstrdup (opt);
  6781. + return NULL;
  6782. +}
  6783. +
  6784. +int
  6785. +label_create_file (const char *file_label)
  6786. +{
  6787. +#ifdef HAVE_SELINUX
  6788. + if (is_selinux_enabled () > 0 && file_label)
  6789. + return setfscreatecon ((security_context_t) file_label);
  6790. +#endif
  6791. + return 0;
  6792. +}
  6793. +
  6794. +int
  6795. +label_exec (const char *exec_label)
  6796. +{
  6797. +#ifdef HAVE_SELINUX
  6798. + if (is_selinux_enabled () > 0 && exec_label)
  6799. + return setexeccon ((security_context_t) exec_label);
  6800. +#endif
  6801. + return 0;
  6802. +}
  6803. diff -Nuar flatpak-1.0.0.orig/bubblewrap/utils.h flatpak-1.0.0/bubblewrap/utils.h
  6804. --- flatpak-1.0.0.orig/bubblewrap/utils.h 1970-01-01 02:00:00.000000000 +0200
  6805. +++ flatpak-1.0.0/bubblewrap/utils.h 2018-02-03 21:26:06.274233339 +0300
  6806. @@ -0,0 +1,166 @@
  6807. +/* bubblewrap
  6808. + * Copyright (C) 2016 Alexander Larsson
  6809. + *
  6810. + * This program is free software; you can redistribute it and/or
  6811. + * modify it under the terms of the GNU Lesser General Public
  6812. + * License as published by the Free Software Foundation; either
  6813. + * version 2 of the License, or (at your option) any later version.
  6814. + *
  6815. + * This library is distributed in the hope that it will be useful,
  6816. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  6817. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6818. + * Lesser General Public License for more details.
  6819. + *
  6820. + * You should have received a copy of the GNU Lesser General Public
  6821. + * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  6822. + *
  6823. + */
  6824. +
  6825. +#pragma once
  6826. +
  6827. +#include <assert.h>
  6828. +#include <dirent.h>
  6829. +#include <errno.h>
  6830. +#include <fcntl.h>
  6831. +#include <stdarg.h>
  6832. +#include <stdio.h>
  6833. +#include <stdlib.h>
  6834. +#include <string.h>
  6835. +#include <unistd.h>
  6836. +#include <sys/types.h>
  6837. +#include <sys/stat.h>
  6838. +
  6839. +#if 0
  6840. +#define __debug__(x) printf x
  6841. +#else
  6842. +#define __debug__(x)
  6843. +#endif
  6844. +
  6845. +#define UNUSED __attribute__((__unused__))
  6846. +
  6847. +#define N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
  6848. +
  6849. +#define TRUE 1
  6850. +#define FALSE 0
  6851. +typedef int bool;
  6852. +
  6853. +#define PIPE_READ_END 0
  6854. +#define PIPE_WRITE_END 1
  6855. +
  6856. +void die_with_error (const char *format,
  6857. + ...) __attribute__((__noreturn__)) __attribute__((format (printf, 1, 2)));
  6858. +void die (const char *format,
  6859. + ...) __attribute__((__noreturn__)) __attribute__((format (printf, 1, 2)));
  6860. +void die_oom (void) __attribute__((__noreturn__));
  6861. +void die_unless_label_valid (const char *label);
  6862. +
  6863. +void *xmalloc (size_t size);
  6864. +void *xcalloc (size_t size);
  6865. +void *xrealloc (void *ptr,
  6866. + size_t size);
  6867. +char *xstrdup (const char *str);
  6868. +void strfreev (char **str_array);
  6869. +void xsetenv (const char *name,
  6870. + const char *value,
  6871. + int overwrite);
  6872. +void xunsetenv (const char *name);
  6873. +char *strconcat (const char *s1,
  6874. + const char *s2);
  6875. +char *strconcat3 (const char *s1,
  6876. + const char *s2,
  6877. + const char *s3);
  6878. +char * xasprintf (const char *format,
  6879. + ...) __attribute__((format (printf, 1, 2)));
  6880. +bool has_prefix (const char *str,
  6881. + const char *prefix);
  6882. +bool has_path_prefix (const char *str,
  6883. + const char *prefix);
  6884. +bool path_equal (const char *path1,
  6885. + const char *path2);
  6886. +int fdwalk (int proc_fd,
  6887. + int (*cb)(void *data,
  6888. + int fd),
  6889. + void *data);
  6890. +char *load_file_data (int fd,
  6891. + size_t *size);
  6892. +char *load_file_at (int dirfd,
  6893. + const char *path);
  6894. +int write_file_at (int dirfd,
  6895. + const char *path,
  6896. + const char *content);
  6897. +int write_to_fd (int fd,
  6898. + const char *content,
  6899. + ssize_t len);
  6900. +int copy_file_data (int sfd,
  6901. + int dfd);
  6902. +int copy_file (const char *src_path,
  6903. + const char *dst_path,
  6904. + mode_t mode);
  6905. +int create_file (const char *path,
  6906. + mode_t mode,
  6907. + const char *content);
  6908. +int ensure_file (const char *path,
  6909. + mode_t mode);
  6910. +int get_file_mode (const char *pathname);
  6911. +int mkdir_with_parents (const char *pathname,
  6912. + int mode,
  6913. + bool create_last);
  6914. +
  6915. +/* syscall wrappers */
  6916. +int raw_clone (unsigned long flags,
  6917. + void *child_stack);
  6918. +int pivot_root (const char *new_root,
  6919. + const char *put_old);
  6920. +char *label_mount (const char *opt,
  6921. + const char *mount_label);
  6922. +int label_exec (const char *exec_label);
  6923. +int label_create_file (const char *file_label);
  6924. +
  6925. +static inline void
  6926. +cleanup_freep (void *p)
  6927. +{
  6928. + void **pp = (void **) p;
  6929. +
  6930. + if (*pp)
  6931. + free (*pp);
  6932. +}
  6933. +
  6934. +static inline void
  6935. +cleanup_strvp (void *p)
  6936. +{
  6937. + void **pp = (void **) p;
  6938. +
  6939. + strfreev (*pp);
  6940. +}
  6941. +
  6942. +static inline void
  6943. +cleanup_fdp (int *fdp)
  6944. +{
  6945. + int fd;
  6946. +
  6947. + assert (fdp);
  6948. +
  6949. + fd = *fdp;
  6950. + if (fd != -1)
  6951. + (void) close (fd);
  6952. +}
  6953. +
  6954. +#define cleanup_free __attribute__((cleanup (cleanup_freep)))
  6955. +#define cleanup_fd __attribute__((cleanup (cleanup_fdp)))
  6956. +#define cleanup_strv __attribute__((cleanup (cleanup_strvp)))
  6957. +
  6958. +static inline void *
  6959. +steal_pointer (void *pp)
  6960. +{
  6961. + void **ptr = (void **) pp;
  6962. + void *ref;
  6963. +
  6964. + ref = *ptr;
  6965. + *ptr = NULL;
  6966. +
  6967. + return ref;
  6968. +}
  6969. +
  6970. +/* type safety */
  6971. +#define steal_pointer(pp) \
  6972. + (0 ? (*(pp)) : (steal_pointer) (pp))
  6973. diff -Nuar flatpak-1.0.0.orig/libglnx/COPYING flatpak-1.0.0/libglnx/COPYING
  6974. --- flatpak-1.0.0.orig/libglnx/COPYING 1970-01-01 02:00:00.000000000 +0200
  6975. +++ flatpak-1.0.0/libglnx/COPYING 2018-02-03 21:26:06.307233341 +0300
  6976. @@ -0,0 +1,502 @@
  6977. + GNU LESSER GENERAL PUBLIC LICENSE
  6978. + Version 2.1, February 1999
  6979. +
  6980. + Copyright (C) 1991, 1999 Free Software Foundation, Inc.
  6981. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  6982. + Everyone is permitted to copy and distribute verbatim copies
  6983. + of this license document, but changing it is not allowed.
  6984. +
  6985. +[This is the first released version of the Lesser GPL. It also counts
  6986. + as the successor of the GNU Library Public License, version 2, hence
  6987. + the version number 2.1.]
  6988. +
  6989. + Preamble
  6990. +
  6991. + The licenses for most software are designed to take away your
  6992. +freedom to share and change it. By contrast, the GNU General Public
  6993. +Licenses are intended to guarantee your freedom to share and change
  6994. +free software--to make sure the software is free for all its users.
  6995. +
  6996. + This license, the Lesser General Public License, applies to some
  6997. +specially designated software packages--typically libraries--of the
  6998. +Free Software Foundation and other authors who decide to use it. You
  6999. +can use it too, but we suggest you first think carefully about whether
  7000. +this license or the ordinary General Public License is the better
  7001. +strategy to use in any particular case, based on the explanations below.
  7002. +
  7003. + When we speak of free software, we are referring to freedom of use,
  7004. +not price. Our General Public Licenses are designed to make sure that
  7005. +you have the freedom to distribute copies of free software (and charge
  7006. +for this service if you wish); that you receive source code or can get
  7007. +it if you want it; that you can change the software and use pieces of
  7008. +it in new free programs; and that you are informed that you can do
  7009. +these things.
  7010. +
  7011. + To protect your rights, we need to make restrictions that forbid
  7012. +distributors to deny you these rights or to ask you to surrender these
  7013. +rights. These restrictions translate to certain responsibilities for
  7014. +you if you distribute copies of the library or if you modify it.
  7015. +
  7016. + For example, if you distribute copies of the library, whether gratis
  7017. +or for a fee, you must give the recipients all the rights that we gave
  7018. +you. You must make sure that they, too, receive or can get the source
  7019. +code. If you link other code with the library, you must provide
  7020. +complete object files to the recipients, so that they can relink them
  7021. +with the library after making changes to the library and recompiling
  7022. +it. And you must show them these terms so they know their rights.
  7023. +
  7024. + We protect your rights with a two-step method: (1) we copyright the
  7025. +library, and (2) we offer you this license, which gives you legal
  7026. +permission to copy, distribute and/or modify the library.
  7027. +
  7028. + To protect each distributor, we want to make it very clear that
  7029. +there is no warranty for the free library. Also, if the library is
  7030. +modified by someone else and passed on, the recipients should know
  7031. +that what they have is not the original version, so that the original
  7032. +author's reputation will not be affected by problems that might be
  7033. +introduced by others.
  7034. +
  7035. + Finally, software patents pose a constant threat to the existence of
  7036. +any free program. We wish to make sure that a company cannot
  7037. +effectively restrict the users of a free program by obtaining a
  7038. +restrictive license from a patent holder. Therefore, we insist that
  7039. +any patent license obtained for a version of the library must be
  7040. +consistent with the full freedom of use specified in this license.
  7041. +
  7042. + Most GNU software, including some libraries, is covered by the
  7043. +ordinary GNU General Public License. This license, the GNU Lesser
  7044. +General Public License, applies to certain designated libraries, and
  7045. +is quite different from the ordinary General Public License. We use
  7046. +this license for certain libraries in order to permit linking those
  7047. +libraries into non-free programs.
  7048. +
  7049. + When a program is linked with a library, whether statically or using
  7050. +a shared library, the combination of the two is legally speaking a
  7051. +combined work, a derivative of the original library. The ordinary
  7052. +General Public License therefore permits such linking only if the
  7053. +entire combination fits its criteria of freedom. The Lesser General
  7054. +Public License permits more lax criteria for linking other code with
  7055. +the library.
  7056. +
  7057. + We call this license the "Lesser" General Public License because it
  7058. +does Less to protect the user's freedom than the ordinary General
  7059. +Public License. It also provides other free software developers Less
  7060. +of an advantage over competing non-free programs. These disadvantages
  7061. +are the reason we use the ordinary General Public License for many
  7062. +libraries. However, the Lesser license provides advantages in certain
  7063. +special circumstances.
  7064. +
  7065. + For example, on rare occasions, there may be a special need to
  7066. +encourage the widest possible use of a certain library, so that it becomes
  7067. +a de-facto standard. To achieve this, non-free programs must be
  7068. +allowed to use the library. A more frequent case is that a free
  7069. +library does the same job as widely used non-free libraries. In this
  7070. +case, there is little to gain by limiting the free library to free
  7071. +software only, so we use the Lesser General Public License.
  7072. +
  7073. + In other cases, permission to use a particular library in non-free
  7074. +programs enables a greater number of people to use a large body of
  7075. +free software. For example, permission to use the GNU C Library in
  7076. +non-free programs enables many more people to use the whole GNU
  7077. +operating system, as well as its variant, the GNU/Linux operating
  7078. +system.
  7079. +
  7080. + Although the Lesser General Public License is Less protective of the
  7081. +users' freedom, it does ensure that the user of a program that is
  7082. +linked with the Library has the freedom and the wherewithal to run
  7083. +that program using a modified version of the Library.
  7084. +
  7085. + The precise terms and conditions for copying, distribution and
  7086. +modification follow. Pay close attention to the difference between a
  7087. +"work based on the library" and a "work that uses the library". The
  7088. +former contains code derived from the library, whereas the latter must
  7089. +be combined with the library in order to run.
  7090. +
  7091. + GNU LESSER GENERAL PUBLIC LICENSE
  7092. + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  7093. +
  7094. + 0. This License Agreement applies to any software library or other
  7095. +program which contains a notice placed by the copyright holder or
  7096. +other authorized party saying it may be distributed under the terms of
  7097. +this Lesser General Public License (also called "this License").
  7098. +Each licensee is addressed as "you".
  7099. +
  7100. + A "library" means a collection of software functions and/or data
  7101. +prepared so as to be conveniently linked with application programs
  7102. +(which use some of those functions and data) to form executables.
  7103. +
  7104. + The "Library", below, refers to any such software library or work
  7105. +which has been distributed under these terms. A "work based on the
  7106. +Library" means either the Library or any derivative work under
  7107. +copyright law: that is to say, a work containing the Library or a
  7108. +portion of it, either verbatim or with modifications and/or translated
  7109. +straightforwardly into another language. (Hereinafter, translation is
  7110. +included without limitation in the term "modification".)
  7111. +
  7112. + "Source code" for a work means the preferred form of the work for
  7113. +making modifications to it. For a library, complete source code means
  7114. +all the source code for all modules it contains, plus any associated
  7115. +interface definition files, plus the scripts used to control compilation
  7116. +and installation of the library.
  7117. +
  7118. + Activities other than copying, distribution and modification are not
  7119. +covered by this License; they are outside its scope. The act of
  7120. +running a program using the Library is not restricted, and output from
  7121. +such a program is covered only if its contents constitute a work based
  7122. +on the Library (independent of the use of the Library in a tool for
  7123. +writing it). Whether that is true depends on what the Library does
  7124. +and what the program that uses the Library does.
  7125. +
  7126. + 1. You may copy and distribute verbatim copies of the Library's
  7127. +complete source code as you receive it, in any medium, provided that
  7128. +you conspicuously and appropriately publish on each copy an
  7129. +appropriate copyright notice and disclaimer of warranty; keep intact
  7130. +all the notices that refer to this License and to the absence of any
  7131. +warranty; and distribute a copy of this License along with the
  7132. +Library.
  7133. +
  7134. + You may charge a fee for the physical act of transferring a copy,
  7135. +and you may at your option offer warranty protection in exchange for a
  7136. +fee.
  7137. +
  7138. + 2. You may modify your copy or copies of the Library or any portion
  7139. +of it, thus forming a work based on the Library, and copy and
  7140. +distribute such modifications or work under the terms of Section 1
  7141. +above, provided that you also meet all of these conditions:
  7142. +
  7143. + a) The modified work must itself be a software library.
  7144. +
  7145. + b) You must cause the files modified to carry prominent notices
  7146. + stating that you changed the files and the date of any change.
  7147. +
  7148. + c) You must cause the whole of the work to be licensed at no
  7149. + charge to all third parties under the terms of this License.
  7150. +
  7151. + d) If a facility in the modified Library refers to a function or a
  7152. + table of data to be supplied by an application program that uses
  7153. + the facility, other than as an argument passed when the facility
  7154. + is invoked, then you must make a good faith effort to ensure that,
  7155. + in the event an application does not supply such function or
  7156. + table, the facility still operates, and performs whatever part of
  7157. + its purpose remains meaningful.
  7158. +
  7159. + (For example, a function in a library to compute square roots has
  7160. + a purpose that is entirely well-defined independent of the
  7161. + application. Therefore, Subsection 2d requires that any
  7162. + application-supplied function or table used by this function must
  7163. + be optional: if the application does not supply it, the square
  7164. + root function must still compute square roots.)
  7165. +
  7166. +These requirements apply to the modified work as a whole. If
  7167. +identifiable sections of that work are not derived from the Library,
  7168. +and can be reasonably considered independent and separate works in
  7169. +themselves, then this License, and its terms, do not apply to those
  7170. +sections when you distribute them as separate works. But when you
  7171. +distribute the same sections as part of a whole which is a work based
  7172. +on the Library, the distribution of the whole must be on the terms of
  7173. +this License, whose permissions for other licensees extend to the
  7174. +entire whole, and thus to each and every part regardless of who wrote
  7175. +it.
  7176. +
  7177. +Thus, it is not the intent of this section to claim rights or contest
  7178. +your rights to work written entirely by you; rather, the intent is to
  7179. +exercise the right to control the distribution of derivative or
  7180. +collective works based on the Library.
  7181. +
  7182. +In addition, mere aggregation of another work not based on the Library
  7183. +with the Library (or with a work based on the Library) on a volume of
  7184. +a storage or distribution medium does not bring the other work under
  7185. +the scope of this License.
  7186. +
  7187. + 3. You may opt to apply the terms of the ordinary GNU General Public
  7188. +License instead of this License to a given copy of the Library. To do
  7189. +this, you must alter all the notices that refer to this License, so
  7190. +that they refer to the ordinary GNU General Public License, version 2,
  7191. +instead of to this License. (If a newer version than version 2 of the
  7192. +ordinary GNU General Public License has appeared, then you can specify
  7193. +that version instead if you wish.) Do not make any other change in
  7194. +these notices.
  7195. +
  7196. + Once this change is made in a given copy, it is irreversible for
  7197. +that copy, so the ordinary GNU General Public License applies to all
  7198. +subsequent copies and derivative works made from that copy.
  7199. +
  7200. + This option is useful when you wish to copy part of the code of
  7201. +the Library into a program that is not a library.
  7202. +
  7203. + 4. You may copy and distribute the Library (or a portion or
  7204. +derivative of it, under Section 2) in object code or executable form
  7205. +under the terms of Sections 1 and 2 above provided that you accompany
  7206. +it with the complete corresponding machine-readable source code, which
  7207. +must be distributed under the terms of Sections 1 and 2 above on a
  7208. +medium customarily used for software interchange.
  7209. +
  7210. + If distribution of object code is made by offering access to copy
  7211. +from a designated place, then offering equivalent access to copy the
  7212. +source code from the same place satisfies the requirement to
  7213. +distribute the source code, even though third parties are not
  7214. +compelled to copy the source along with the object code.
  7215. +
  7216. + 5. A program that contains no derivative of any portion of the
  7217. +Library, but is designed to work with the Library by being compiled or
  7218. +linked with it, is called a "work that uses the Library". Such a
  7219. +work, in isolation, is not a derivative work of the Library, and
  7220. +therefore falls outside the scope of this License.
  7221. +
  7222. + However, linking a "work that uses the Library" with the Library
  7223. +creates an executable that is a derivative of the Library (because it
  7224. +contains portions of the Library), rather than a "work that uses the
  7225. +library". The executable is therefore covered by this License.
  7226. +Section 6 states terms for distribution of such executables.
  7227. +
  7228. + When a "work that uses the Library" uses material from a header file
  7229. +that is part of the Library, the object code for the work may be a
  7230. +derivative work of the Library even though the source code is not.
  7231. +Whether this is true is especially significant if the work can be
  7232. +linked without the Library, or if the work is itself a library. The
  7233. +threshold for this to be true is not precisely defined by law.
  7234. +
  7235. + If such an object file uses only numerical parameters, data
  7236. +structure layouts and accessors, and small macros and small inline
  7237. +functions (ten lines or less in length), then the use of the object
  7238. +file is unrestricted, regardless of whether it is legally a derivative
  7239. +work. (Executables containing this object code plus portions of the
  7240. +Library will still fall under Section 6.)
  7241. +
  7242. + Otherwise, if the work is a derivative of the Library, you may
  7243. +distribute the object code for the work under the terms of Section 6.
  7244. +Any executables containing that work also fall under Section 6,
  7245. +whether or not they are linked directly with the Library itself.
  7246. +
  7247. + 6. As an exception to the Sections above, you may also combine or
  7248. +link a "work that uses the Library" with the Library to produce a
  7249. +work containing portions of the Library, and distribute that work
  7250. +under terms of your choice, provided that the terms permit
  7251. +modification of the work for the customer's own use and reverse
  7252. +engineering for debugging such modifications.
  7253. +
  7254. + You must give prominent notice with each copy of the work that the
  7255. +Library is used in it and that the Library and its use are covered by
  7256. +this License. You must supply a copy of this License. If the work
  7257. +during execution displays copyright notices, you must include the
  7258. +copyright notice for the Library among them, as well as a reference
  7259. +directing the user to the copy of this License. Also, you must do one
  7260. +of these things:
  7261. +
  7262. + a) Accompany the work with the complete corresponding
  7263. + machine-readable source code for the Library including whatever
  7264. + changes were used in the work (which must be distributed under
  7265. + Sections 1 and 2 above); and, if the work is an executable linked
  7266. + with the Library, with the complete machine-readable "work that
  7267. + uses the Library", as object code and/or source code, so that the
  7268. + user can modify the Library and then relink to produce a modified
  7269. + executable containing the modified Library. (It is understood
  7270. + that the user who changes the contents of definitions files in the
  7271. + Library will not necessarily be able to recompile the application
  7272. + to use the modified definitions.)
  7273. +
  7274. + b) Use a suitable shared library mechanism for linking with the
  7275. + Library. A suitable mechanism is one that (1) uses at run time a
  7276. + copy of the library already present on the user's computer system,
  7277. + rather than copying library functions into the executable, and (2)
  7278. + will operate properly with a modified version of the library, if
  7279. + the user installs one, as long as the modified version is
  7280. + interface-compatible with the version that the work was made with.
  7281. +
  7282. + c) Accompany the work with a written offer, valid for at
  7283. + least three years, to give the same user the materials
  7284. + specified in Subsection 6a, above, for a charge no more
  7285. + than the cost of performing this distribution.
  7286. +
  7287. + d) If distribution of the work is made by offering access to copy
  7288. + from a designated place, offer equivalent access to copy the above
  7289. + specified materials from the same place.
  7290. +
  7291. + e) Verify that the user has already received a copy of these
  7292. + materials or that you have already sent this user a copy.
  7293. +
  7294. + For an executable, the required form of the "work that uses the
  7295. +Library" must include any data and utility programs needed for
  7296. +reproducing the executable from it. However, as a special exception,
  7297. +the materials to be distributed need not include anything that is
  7298. +normally distributed (in either source or binary form) with the major
  7299. +components (compiler, kernel, and so on) of the operating system on
  7300. +which the executable runs, unless that component itself accompanies
  7301. +the executable.
  7302. +
  7303. + It may happen that this requirement contradicts the license
  7304. +restrictions of other proprietary libraries that do not normally
  7305. +accompany the operating system. Such a contradiction means you cannot
  7306. +use both them and the Library together in an executable that you
  7307. +distribute.
  7308. +
  7309. + 7. You may place library facilities that are a work based on the
  7310. +Library side-by-side in a single library together with other library
  7311. +facilities not covered by this License, and distribute such a combined
  7312. +library, provided that the separate distribution of the work based on
  7313. +the Library and of the other library facilities is otherwise
  7314. +permitted, and provided that you do these two things:
  7315. +
  7316. + a) Accompany the combined library with a copy of the same work
  7317. + based on the Library, uncombined with any other library
  7318. + facilities. This must be distributed under the terms of the
  7319. + Sections above.
  7320. +
  7321. + b) Give prominent notice with the combined library of the fact
  7322. + that part of it is a work based on the Library, and explaining
  7323. + where to find the accompanying uncombined form of the same work.
  7324. +
  7325. + 8. You may not copy, modify, sublicense, link with, or distribute
  7326. +the Library except as expressly provided under this License. Any
  7327. +attempt otherwise to copy, modify, sublicense, link with, or
  7328. +distribute the Library is void, and will automatically terminate your
  7329. +rights under this License. However, parties who have received copies,
  7330. +or rights, from you under this License will not have their licenses
  7331. +terminated so long as such parties remain in full compliance.
  7332. +
  7333. + 9. You are not required to accept this License, since you have not
  7334. +signed it. However, nothing else grants you permission to modify or
  7335. +distribute the Library or its derivative works. These actions are
  7336. +prohibited by law if you do not accept this License. Therefore, by
  7337. +modifying or distributing the Library (or any work based on the
  7338. +Library), you indicate your acceptance of this License to do so, and
  7339. +all its terms and conditions for copying, distributing or modifying
  7340. +the Library or works based on it.
  7341. +
  7342. + 10. Each time you redistribute the Library (or any work based on the
  7343. +Library), the recipient automatically receives a license from the
  7344. +original licensor to copy, distribute, link with or modify the Library
  7345. +subject to these terms and conditions. You may not impose any further
  7346. +restrictions on the recipients' exercise of the rights granted herein.
  7347. +You are not responsible for enforcing compliance by third parties with
  7348. +this License.
  7349. +
  7350. + 11. If, as a consequence of a court judgment or allegation of patent
  7351. +infringement or for any other reason (not limited to patent issues),
  7352. +conditions are imposed on you (whether by court order, agreement or
  7353. +otherwise) that contradict the conditions of this License, they do not
  7354. +excuse you from the conditions of this License. If you cannot
  7355. +distribute so as to satisfy simultaneously your obligations under this
  7356. +License and any other pertinent obligations, then as a consequence you
  7357. +may not distribute the Library at all. For example, if a patent
  7358. +license would not permit royalty-free redistribution of the Library by
  7359. +all those who receive copies directly or indirectly through you, then
  7360. +the only way you could satisfy both it and this License would be to
  7361. +refrain entirely from distribution of the Library.
  7362. +
  7363. +If any portion of this section is held invalid or unenforceable under any
  7364. +particular circumstance, the balance of the section is intended to apply,
  7365. +and the section as a whole is intended to apply in other circumstances.
  7366. +
  7367. +It is not the purpose of this section to induce you to infringe any
  7368. +patents or other property right claims or to contest validity of any
  7369. +such claims; this section has the sole purpose of protecting the
  7370. +integrity of the free software distribution system which is
  7371. +implemented by public license practices. Many people have made
  7372. +generous contributions to the wide range of software distributed
  7373. +through that system in reliance on consistent application of that
  7374. +system; it is up to the author/donor to decide if he or she is willing
  7375. +to distribute software through any other system and a licensee cannot
  7376. +impose that choice.
  7377. +
  7378. +This section is intended to make thoroughly clear what is believed to
  7379. +be a consequence of the rest of this License.
  7380. +
  7381. + 12. If the distribution and/or use of the Library is restricted in
  7382. +certain countries either by patents or by copyrighted interfaces, the
  7383. +original copyright holder who places the Library under this License may add
  7384. +an explicit geographical distribution limitation excluding those countries,
  7385. +so that distribution is permitted only in or among countries not thus
  7386. +excluded. In such case, this License incorporates the limitation as if
  7387. +written in the body of this License.
  7388. +
  7389. + 13. The Free Software Foundation may publish revised and/or new
  7390. +versions of the Lesser General Public License from time to time.
  7391. +Such new versions will be similar in spirit to the present version,
  7392. +but may differ in detail to address new problems or concerns.
  7393. +
  7394. +Each version is given a distinguishing version number. If the Library
  7395. +specifies a version number of this License which applies to it and
  7396. +"any later version", you have the option of following the terms and
  7397. +conditions either of that version or of any later version published by
  7398. +the Free Software Foundation. If the Library does not specify a
  7399. +license version number, you may choose any version ever published by
  7400. +the Free Software Foundation.
  7401. +
  7402. + 14. If you wish to incorporate parts of the Library into other free
  7403. +programs whose distribution conditions are incompatible with these,
  7404. +write to the author to ask for permission. For software which is
  7405. +copyrighted by the Free Software Foundation, write to the Free
  7406. +Software Foundation; we sometimes make exceptions for this. Our
  7407. +decision will be guided by the two goals of preserving the free status
  7408. +of all derivatives of our free software and of promoting the sharing
  7409. +and reuse of software generally.
  7410. +
  7411. + NO WARRANTY
  7412. +
  7413. + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  7414. +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  7415. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  7416. +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  7417. +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  7418. +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  7419. +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  7420. +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  7421. +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  7422. +
  7423. + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  7424. +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  7425. +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  7426. +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  7427. +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  7428. +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  7429. +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  7430. +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  7431. +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  7432. +DAMAGES.
  7433. +
  7434. + END OF TERMS AND CONDITIONS
  7435. +
  7436. + How to Apply These Terms to Your New Libraries
  7437. +
  7438. + If you develop a new library, and you want it to be of the greatest
  7439. +possible use to the public, we recommend making it free software that
  7440. +everyone can redistribute and change. You can do so by permitting
  7441. +redistribution under these terms (or, alternatively, under the terms of the
  7442. +ordinary General Public License).
  7443. +
  7444. + To apply these terms, attach the following notices to the library. It is
  7445. +safest to attach them to the start of each source file to most effectively
  7446. +convey the exclusion of warranty; and each file should have at least the
  7447. +"copyright" line and a pointer to where the full notice is found.
  7448. +
  7449. + <one line to give the library's name and a brief idea of what it does.>
  7450. + Copyright (C) <year> <name of author>
  7451. +
  7452. + This library is free software; you can redistribute it and/or
  7453. + modify it under the terms of the GNU Lesser General Public
  7454. + License as published by the Free Software Foundation; either
  7455. + version 2.1 of the License, or (at your option) any later version.
  7456. +
  7457. + This library is distributed in the hope that it will be useful,
  7458. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  7459. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7460. + Lesser General Public License for more details.
  7461. +
  7462. + You should have received a copy of the GNU Lesser General Public
  7463. + License along with this library; if not, write to the Free Software
  7464. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  7465. +
  7466. +Also add information on how to contact you by electronic and paper mail.
  7467. +
  7468. +You should also get your employer (if you work as a programmer) or your
  7469. +school, if any, to sign a "copyright disclaimer" for the library, if
  7470. +necessary. Here is a sample; alter the names:
  7471. +
  7472. + Yoyodyne, Inc., hereby disclaims all copyright interest in the
  7473. + library `Frob' (a library for tweaking knobs) written by James Random Hacker.
  7474. +
  7475. + <signature of Ty Coon>, 1 April 1990
  7476. + Ty Coon, President of Vice
  7477. +
  7478. +That's all there is to it!
  7479. diff -Nuar flatpak-1.0.0.orig/libglnx/.git flatpak-1.0.0/libglnx/.git
  7480. --- flatpak-1.0.0.orig/libglnx/.git 1970-01-01 02:00:00.000000000 +0200
  7481. +++ flatpak-1.0.0/libglnx/.git 2018-02-03 21:26:06.241233337 +0300
  7482. @@ -0,0 +1 @@
  7483. +gitdir: ../.git/modules/libglnx
  7484. diff -Nuar flatpak-1.0.0.orig/libglnx/.gitignore flatpak-1.0.0/libglnx/.gitignore
  7485. --- flatpak-1.0.0.orig/libglnx/.gitignore 1970-01-01 02:00:00.000000000 +0200
  7486. +++ flatpak-1.0.0/libglnx/.gitignore 2018-02-03 21:26:06.307233341 +0300
  7487. @@ -0,0 +1,16 @@
  7488. +# A path ostree writes to work around automake bug with
  7489. +# subdir-objects
  7490. +Makefile-libglnx.am.inc
  7491. +
  7492. +# Some standard bits
  7493. +.deps
  7494. +.libs
  7495. +.dirstamp
  7496. +*.typelib
  7497. +*.la
  7498. +*.lo
  7499. +*.o
  7500. +*.pyc
  7501. +*.stamp
  7502. +*~
  7503. +
  7504. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-backport-autocleanups.h flatpak-1.0.0/libglnx/glnx-backport-autocleanups.h
  7505. --- flatpak-1.0.0.orig/libglnx/glnx-backport-autocleanups.h 1970-01-01 02:00:00.000000000 +0200
  7506. +++ flatpak-1.0.0/libglnx/glnx-backport-autocleanups.h 2018-02-03 21:26:06.307233341 +0300
  7507. @@ -0,0 +1,124 @@
  7508. +/*
  7509. + * Copyright © 2015 Canonical Limited
  7510. + *
  7511. + * This library is free software; you can redistribute it and/or
  7512. + * modify it under the terms of the GNU Lesser General Public
  7513. + * License as published by the Free Software Foundation; either
  7514. + * version 2 of the licence, or (at your option) any later version.
  7515. + *
  7516. + * This library is distributed in the hope that it will be useful,
  7517. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7518. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7519. + * Lesser General Public License for more details.
  7520. + *
  7521. + * You should have received a copy of the GNU Lesser General Public
  7522. + * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  7523. + *
  7524. + * Author: Ryan Lortie <desrt@desrt.ca>
  7525. + */
  7526. +
  7527. +#pragma once
  7528. +
  7529. +#include <glnx-backport-autoptr.h>
  7530. +
  7531. +#if !GLIB_CHECK_VERSION(2, 43, 4)
  7532. +
  7533. +static inline void
  7534. +g_autoptr_cleanup_generic_gfree (void *p)
  7535. +{
  7536. + void **pp = (void**)p;
  7537. + if (*pp)
  7538. + g_free (*pp);
  7539. +}
  7540. +
  7541. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref)
  7542. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free)
  7543. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBytes, g_bytes_unref)
  7544. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GChecksum, g_checksum_free)
  7545. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDateTime, g_date_time_unref)
  7546. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDir, g_dir_close)
  7547. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GError, g_error_free)
  7548. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHashTable, g_hash_table_unref)
  7549. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GHmac, g_hmac_unref)
  7550. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GIOChannel, g_io_channel_unref)
  7551. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GKeyFile, g_key_file_unref)
  7552. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GList, g_list_free)
  7553. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GArray, g_array_unref)
  7554. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPtrArray, g_ptr_array_unref)
  7555. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainContext, g_main_context_unref)
  7556. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMainLoop, g_main_loop_unref)
  7557. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSource, g_source_unref)
  7558. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMappedFile, g_mapped_file_unref)
  7559. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMarkupParseContext, g_markup_parse_context_unref)
  7560. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(gchar, g_free)
  7561. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GNode, g_node_destroy)
  7562. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionContext, g_option_context_free)
  7563. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOptionGroup, g_option_group_free)
  7564. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GPatternSpec, g_pattern_spec_free)
  7565. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GQueue, g_queue_free)
  7566. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GQueue, g_queue_clear)
  7567. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRand, g_rand_free)
  7568. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GRegex, g_regex_unref)
  7569. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMatchInfo, g_match_info_unref)
  7570. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GScanner, g_scanner_destroy)
  7571. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSequence, g_sequence_free)
  7572. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSList, g_slist_free)
  7573. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GStringChunk, g_string_chunk_free)
  7574. +G_DEFINE_AUTO_CLEANUP_FREE_FUNC(GStrv, g_strfreev, NULL)
  7575. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GThread, g_thread_unref)
  7576. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GMutex, g_mutex_clear)
  7577. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GCond, g_cond_clear)
  7578. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimer, g_timer_destroy)
  7579. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTimeZone, g_time_zone_unref)
  7580. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTree, g_tree_unref)
  7581. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariant, g_variant_unref)
  7582. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantBuilder, g_variant_builder_unref)
  7583. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantBuilder, g_variant_builder_clear)
  7584. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantIter, g_variant_iter_free)
  7585. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantDict, g_variant_dict_unref)
  7586. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GVariantDict, g_variant_dict_clear)
  7587. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GVariantType, g_variant_type_free)
  7588. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSubprocess, g_object_unref)
  7589. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSubprocessLauncher, g_object_unref)
  7590. +
  7591. +/* Add GObject-based types as needed. */
  7592. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GCancellable, g_object_unref)
  7593. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GConverter, g_object_unref)
  7594. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GConverterOutputStream, g_object_unref)
  7595. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDataInputStream, g_object_unref)
  7596. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFile, g_object_unref)
  7597. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileEnumerator, g_object_unref)
  7598. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileIOStream, g_object_unref)
  7599. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileInfo, g_object_unref)
  7600. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileInputStream, g_object_unref)
  7601. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileMonitor, g_object_unref)
  7602. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GFileOutputStream, g_object_unref)
  7603. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GInputStream, g_object_unref)
  7604. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMemoryInputStream, g_object_unref)
  7605. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GMemoryOutputStream, g_object_unref)
  7606. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GOutputStream, g_object_unref)
  7607. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocket, g_object_unref)
  7608. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GSocketAddress, g_object_unref)
  7609. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTask, g_object_unref)
  7610. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsCertificate, g_object_unref)
  7611. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsDatabase, g_object_unref)
  7612. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GTlsInteraction, g_object_unref)
  7613. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusConnection, g_object_unref)
  7614. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GDBusMessage, g_object_unref)
  7615. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GZlibCompressor, g_object_unref)
  7616. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GZlibDecompressor, g_object_unref)
  7617. +
  7618. +#endif
  7619. +
  7620. +#if !GLIB_CHECK_VERSION(2, 45, 8)
  7621. +
  7622. +static inline void
  7623. +g_autoptr_cleanup_gstring_free (GString *string)
  7624. +{
  7625. + if (string)
  7626. + g_string_free (string, TRUE);
  7627. +}
  7628. +
  7629. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GString, g_autoptr_cleanup_gstring_free)
  7630. +
  7631. +#endif
  7632. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-backport-autoptr.h flatpak-1.0.0/libglnx/glnx-backport-autoptr.h
  7633. --- flatpak-1.0.0.orig/libglnx/glnx-backport-autoptr.h 1970-01-01 02:00:00.000000000 +0200
  7634. +++ flatpak-1.0.0/libglnx/glnx-backport-autoptr.h 2018-02-03 21:26:06.308233341 +0300
  7635. @@ -0,0 +1,133 @@
  7636. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  7637. + *
  7638. + * Copyright (C) 2015 Colin Walters <walters@verbum.org>
  7639. + *
  7640. + * GLIB - Library of useful routines for C programming
  7641. + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  7642. + *
  7643. + * This library is free software; you can redistribute it and/or
  7644. + * modify it under the terms of the GNU Lesser General Public
  7645. + * License as published by the Free Software Foundation; either
  7646. + * version 2 of the License, or (at your option) any later version.
  7647. + *
  7648. + * This library is distributed in the hope that it will be useful,
  7649. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7650. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7651. + * Lesser General Public License for more details.
  7652. + *
  7653. + * You should have received a copy of the GNU Lesser General Public
  7654. + * License along with this library; if not, write to the
  7655. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  7656. + * Boston, MA 02111-1307, USA.
  7657. + */
  7658. +
  7659. +#pragma once
  7660. +
  7661. +#include <gio/gio.h>
  7662. +
  7663. +G_BEGIN_DECLS
  7664. +
  7665. +#if !GLIB_CHECK_VERSION(2, 43, 4)
  7666. +
  7667. +#define _GLIB_AUTOPTR_FUNC_NAME(TypeName) glib_autoptr_cleanup_##TypeName
  7668. +#define _GLIB_AUTOPTR_TYPENAME(TypeName) TypeName##_autoptr
  7669. +#define _GLIB_AUTO_FUNC_NAME(TypeName) glib_auto_cleanup_##TypeName
  7670. +#define _GLIB_CLEANUP(func) __attribute__((cleanup(func)))
  7671. +#define _GLIB_DEFINE_AUTOPTR_CHAINUP(ModuleObjName, ParentName) \
  7672. + typedef ModuleObjName *_GLIB_AUTOPTR_TYPENAME(ModuleObjName); \
  7673. + static inline void _GLIB_AUTOPTR_FUNC_NAME(ModuleObjName) (ModuleObjName **_ptr) { \
  7674. + _GLIB_AUTOPTR_FUNC_NAME(ParentName) ((ParentName **) _ptr); } \
  7675. +
  7676. +
  7677. +/* these macros are API */
  7678. +#define G_DEFINE_AUTOPTR_CLEANUP_FUNC(TypeName, func) \
  7679. + typedef TypeName *_GLIB_AUTOPTR_TYPENAME(TypeName); \
  7680. + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
  7681. + static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
  7682. + G_GNUC_END_IGNORE_DEPRECATIONS
  7683. +#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
  7684. + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
  7685. + static inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { (func) (_ptr); } \
  7686. + G_GNUC_END_IGNORE_DEPRECATIONS
  7687. +#define G_DEFINE_AUTO_CLEANUP_FREE_FUNC(TypeName, func, none) \
  7688. + G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
  7689. + static inline void _GLIB_AUTO_FUNC_NAME(TypeName) (TypeName *_ptr) { if (*_ptr != none) (func) (*_ptr); } \
  7690. + G_GNUC_END_IGNORE_DEPRECATIONS
  7691. +#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName)
  7692. +#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName
  7693. +#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree)
  7694. +
  7695. +/**
  7696. + * g_steal_pointer:
  7697. + * @pp: a pointer to a pointer
  7698. + *
  7699. + * Sets @pp to %NULL, returning the value that was there before.
  7700. + *
  7701. + * Conceptually, this transfers the ownership of the pointer from the
  7702. + * referenced variable to the "caller" of the macro (ie: "steals" the
  7703. + * reference).
  7704. + *
  7705. + * The return value will be properly typed, according to the type of
  7706. + * @pp.
  7707. + *
  7708. + * This can be very useful when combined with g_autoptr() to prevent the
  7709. + * return value of a function from being automatically freed. Consider
  7710. + * the following example (which only works on GCC and clang):
  7711. + *
  7712. + * |[
  7713. + * GObject *
  7714. + * create_object (void)
  7715. + * {
  7716. + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
  7717. + *
  7718. + * if (early_error_case)
  7719. + * return NULL;
  7720. + *
  7721. + * return g_steal_pointer (&obj);
  7722. + * }
  7723. + * ]|
  7724. + *
  7725. + * It can also be used in similar ways for 'out' parameters and is
  7726. + * particularly useful for dealing with optional out parameters:
  7727. + *
  7728. + * |[
  7729. + * gboolean
  7730. + * get_object (GObject **obj_out)
  7731. + * {
  7732. + * g_autoptr(GObject) obj = g_object_new (G_TYPE_OBJECT, NULL);
  7733. + *
  7734. + * if (early_error_case)
  7735. + * return FALSE;
  7736. + *
  7737. + * if (obj_out)
  7738. + * *obj_out = g_steal_pointer (&obj);
  7739. + *
  7740. + * return TRUE;
  7741. + * }
  7742. + * ]|
  7743. + *
  7744. + * In the above example, the object will be automatically freed in the
  7745. + * early error case and also in the case that %NULL was given for
  7746. + * @obj_out.
  7747. + *
  7748. + * Since: 2.44
  7749. + */
  7750. +static inline gpointer
  7751. +(g_steal_pointer) (gpointer pp)
  7752. +{
  7753. + gpointer *ptr = (gpointer *) pp;
  7754. + gpointer ref;
  7755. +
  7756. + ref = *ptr;
  7757. + *ptr = NULL;
  7758. +
  7759. + return ref;
  7760. +}
  7761. +
  7762. +/* type safety */
  7763. +#define g_steal_pointer(pp) \
  7764. + (0 ? (*(pp)) : (g_steal_pointer) (pp))
  7765. +
  7766. +#endif /* !GLIB_CHECK_VERSION(2, 43, 3) */
  7767. +
  7768. +G_END_DECLS
  7769. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-backports.c flatpak-1.0.0/libglnx/glnx-backports.c
  7770. --- flatpak-1.0.0.orig/libglnx/glnx-backports.c 1970-01-01 02:00:00.000000000 +0200
  7771. +++ flatpak-1.0.0/libglnx/glnx-backports.c 2018-02-03 21:26:06.308233341 +0300
  7772. @@ -0,0 +1,61 @@
  7773. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  7774. + *
  7775. + * Copyright (C) 2015 Colin Walters <walters@verbum.org>
  7776. + *
  7777. + * This program is free software: you can redistribute it and/or modify
  7778. + * it under the terms of the GNU Lesser General Public License as published
  7779. + * by the Free Software Foundation; either version 2 of the licence or (at
  7780. + * your option) any later version.
  7781. + *
  7782. + * This library is distributed in the hope that it will be useful,
  7783. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7784. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7785. + * Lesser General Public License for more details.
  7786. + *
  7787. + * You should have received a copy of the GNU Lesser General
  7788. + * Public License along with this library; if not, write to the
  7789. + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  7790. + * Boston, MA 02111-1307, USA.
  7791. + */
  7792. +
  7793. +#include "config.h"
  7794. +
  7795. +#include "glnx-backports.h"
  7796. +
  7797. +#if !GLIB_CHECK_VERSION(2, 44, 0)
  7798. +gboolean
  7799. +glnx_strv_contains (const gchar * const *strv,
  7800. + const gchar *str)
  7801. +{
  7802. + g_return_val_if_fail (strv != NULL, FALSE);
  7803. + g_return_val_if_fail (str != NULL, FALSE);
  7804. +
  7805. + for (; *strv != NULL; strv++)
  7806. + {
  7807. + if (g_str_equal (str, *strv))
  7808. + return TRUE;
  7809. + }
  7810. +
  7811. + return FALSE;
  7812. +}
  7813. +
  7814. +gboolean
  7815. +glnx_set_object (GObject **object_ptr,
  7816. + GObject *new_object)
  7817. +{
  7818. + GObject *old_object = *object_ptr;
  7819. +
  7820. + if (old_object == new_object)
  7821. + return FALSE;
  7822. +
  7823. + if (new_object != NULL)
  7824. + g_object_ref (new_object);
  7825. +
  7826. + *object_ptr = new_object;
  7827. +
  7828. + if (old_object != NULL)
  7829. + g_object_unref (old_object);
  7830. +
  7831. + return TRUE;
  7832. +}
  7833. +#endif
  7834. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-backports.h flatpak-1.0.0/libglnx/glnx-backports.h
  7835. --- flatpak-1.0.0.orig/libglnx/glnx-backports.h 1970-01-01 02:00:00.000000000 +0200
  7836. +++ flatpak-1.0.0/libglnx/glnx-backports.h 2018-02-03 21:26:06.308233341 +0300
  7837. @@ -0,0 +1,46 @@
  7838. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  7839. + *
  7840. + * Copyright (C) 2015 Colin Walters <walters@verbum.org>
  7841. + *
  7842. + * GLIB - Library of useful routines for C programming
  7843. + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  7844. + *
  7845. + * This library is free software; you can redistribute it and/or
  7846. + * modify it under the terms of the GNU Lesser General Public
  7847. + * License as published by the Free Software Foundation; either
  7848. + * version 2 of the License, or (at your option) any later version.
  7849. + *
  7850. + * This library is distributed in the hope that it will be useful,
  7851. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7852. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7853. + * Lesser General Public License for more details.
  7854. + *
  7855. + * You should have received a copy of the GNU Lesser General Public
  7856. + * License along with this library; if not, write to the
  7857. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  7858. + * Boston, MA 02111-1307, USA.
  7859. + */
  7860. +
  7861. +#pragma once
  7862. +
  7863. +#include <gio/gio.h>
  7864. +
  7865. +G_BEGIN_DECLS
  7866. +
  7867. +#if !GLIB_CHECK_VERSION(2, 44, 0)
  7868. +
  7869. +#define g_strv_contains glnx_strv_contains
  7870. +gboolean glnx_strv_contains (const gchar * const *strv,
  7871. + const gchar *str);
  7872. +
  7873. +#define g_set_object(object_ptr, new_object) \
  7874. + (/* Check types match. */ \
  7875. + 0 ? *(object_ptr) = (new_object), FALSE : \
  7876. + glnx_set_object ((GObject **) (object_ptr), (GObject *) (new_object)) \
  7877. + )
  7878. +gboolean glnx_set_object (GObject **object_ptr,
  7879. + GObject *new_object);
  7880. +
  7881. +#endif /* !GLIB_CHECK_VERSION(2, 44, 0) */
  7882. +
  7883. +G_END_DECLS
  7884. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-console.c flatpak-1.0.0/libglnx/glnx-console.c
  7885. --- flatpak-1.0.0.orig/libglnx/glnx-console.c 1970-01-01 02:00:00.000000000 +0200
  7886. +++ flatpak-1.0.0/libglnx/glnx-console.c 2018-05-26 00:50:25.433037228 +0300
  7887. @@ -0,0 +1,359 @@
  7888. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  7889. + *
  7890. + * Copyright (C) 2013,2014,2015 Colin Walters <walters@verbum.org>
  7891. + *
  7892. + * This program is free software: you can redistribute it and/or modify
  7893. + * it under the terms of the GNU Lesser General Public License as published
  7894. + * by the Free Software Foundation; either version 2 of the licence or (at
  7895. + * your option) any later version.
  7896. + *
  7897. + * This library is distributed in the hope that it will be useful,
  7898. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  7899. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7900. + * Lesser General Public License for more details.
  7901. + *
  7902. + * You should have received a copy of the GNU Lesser General
  7903. + * Public License along with this library; if not, write to the
  7904. + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  7905. + * Boston, MA 02111-1307, USA.
  7906. + */
  7907. +
  7908. +#include "config.h"
  7909. +
  7910. +#include "glnx-console.h"
  7911. +
  7912. +#include <unistd.h>
  7913. +#include <string.h>
  7914. +#include <fcntl.h>
  7915. +#include <stdio.h>
  7916. +#include <errno.h>
  7917. +#include <sys/ioctl.h>
  7918. +
  7919. +/* For people with widescreen monitors and maximized terminals, it looks pretty
  7920. + * bad to have an enormous progress bar. For much the same reason as web pages
  7921. + * tend to have a maximum width;
  7922. + * https://ux.stackexchange.com/questions/48982/suggest-good-max-width-for-fluid-width-design
  7923. + */
  7924. +#define MAX_PROGRESSBAR_COLUMNS 20
  7925. +
  7926. +/* Max updates output per second. On a tty there's no point to rendering
  7927. + * extremely fast; and for a non-tty we're probably in a Jenkins job
  7928. + * or whatever and having percentages spam multiple lines there is annoying.
  7929. + */
  7930. +#define MAX_TTY_UPDATE_HZ (5)
  7931. +#define MAX_NONTTY_UPDATE_HZ (1)
  7932. +
  7933. +static gboolean locked;
  7934. +static guint64 last_update_ms; /* monotonic time in millis we last updated */
  7935. +
  7936. +gboolean
  7937. +glnx_stdout_is_tty (void)
  7938. +{
  7939. + static gsize initialized = 0;
  7940. + static gboolean stdout_is_tty_v;
  7941. +
  7942. + if (g_once_init_enter (&initialized))
  7943. + {
  7944. + stdout_is_tty_v = isatty (1);
  7945. + g_once_init_leave (&initialized, 1);
  7946. + }
  7947. +
  7948. + return stdout_is_tty_v;
  7949. +}
  7950. +
  7951. +static volatile guint cached_columns = 0;
  7952. +static volatile guint cached_lines = 0;
  7953. +
  7954. +static int
  7955. +fd_columns (int fd)
  7956. +{
  7957. + struct winsize ws = {};
  7958. +
  7959. + if (ioctl (fd, TIOCGWINSZ, &ws) < 0)
  7960. + return -errno;
  7961. +
  7962. + if (ws.ws_col <= 0)
  7963. + return -EIO;
  7964. +
  7965. + return ws.ws_col;
  7966. +}
  7967. +
  7968. +/**
  7969. + * glnx_console_columns:
  7970. + *
  7971. + * Returns: The number of columns for terminal output
  7972. + */
  7973. +guint
  7974. +glnx_console_columns (void)
  7975. +{
  7976. + if (G_UNLIKELY (cached_columns == 0))
  7977. + {
  7978. + int c;
  7979. +
  7980. + c = fd_columns (STDOUT_FILENO);
  7981. +
  7982. + if (c <= 0)
  7983. + c = 80;
  7984. +
  7985. + if (c > 256)
  7986. + c = 256;
  7987. +
  7988. + cached_columns = c;
  7989. + }
  7990. +
  7991. + return cached_columns;
  7992. +}
  7993. +
  7994. +static int
  7995. +fd_lines (int fd)
  7996. +{
  7997. + struct winsize ws = {};
  7998. +
  7999. + if (ioctl (fd, TIOCGWINSZ, &ws) < 0)
  8000. + return -errno;
  8001. +
  8002. + if (ws.ws_row <= 0)
  8003. + return -EIO;
  8004. +
  8005. + return ws.ws_row;
  8006. +}
  8007. +
  8008. +/**
  8009. + * glnx_console_lines:
  8010. + *
  8011. + * Returns: The number of lines for terminal output
  8012. + */
  8013. +guint
  8014. +glnx_console_lines (void)
  8015. +{
  8016. + if (G_UNLIKELY (cached_lines == 0))
  8017. + {
  8018. + int l;
  8019. +
  8020. + l = fd_lines (STDOUT_FILENO);
  8021. +
  8022. + if (l <= 0)
  8023. + l = 24;
  8024. +
  8025. + cached_lines = l;
  8026. + }
  8027. +
  8028. + return cached_lines;
  8029. +}
  8030. +
  8031. +static void
  8032. +on_sigwinch (int signum)
  8033. +{
  8034. + cached_columns = 0;
  8035. + cached_lines = 0;
  8036. +}
  8037. +
  8038. +void
  8039. +glnx_console_lock (GLnxConsoleRef *console)
  8040. +{
  8041. + static gsize sigwinch_initialized = 0;
  8042. +
  8043. + g_return_if_fail (!locked);
  8044. + g_return_if_fail (!console->locked);
  8045. +
  8046. + console->is_tty = glnx_stdout_is_tty ();
  8047. +
  8048. + locked = console->locked = TRUE;
  8049. +
  8050. + if (console->is_tty)
  8051. + {
  8052. + if (g_once_init_enter (&sigwinch_initialized))
  8053. + {
  8054. + signal (SIGWINCH, on_sigwinch);
  8055. + g_once_init_leave (&sigwinch_initialized, 1);
  8056. + }
  8057. +
  8058. + { static const char initbuf[] = { '\n', 0x1B, 0x37 };
  8059. + (void) fwrite (initbuf, 1, sizeof (initbuf), stdout);
  8060. + }
  8061. + }
  8062. +}
  8063. +
  8064. +static void
  8065. +printpad (const char *padbuf,
  8066. + guint padbuf_len,
  8067. + guint n)
  8068. +{
  8069. + const guint d = n / padbuf_len;
  8070. + const guint r = n % padbuf_len;
  8071. + guint i;
  8072. +
  8073. + for (i = 0; i < d; i++)
  8074. + fwrite (padbuf, 1, padbuf_len, stdout);
  8075. + fwrite (padbuf, 1, r, stdout);
  8076. +}
  8077. +
  8078. +static void
  8079. +text_percent_internal (const char *text,
  8080. + int percentage)
  8081. +{
  8082. + /* Check whether we're trying to render too fast; unless percentage is 100, in
  8083. + * which case we assume this is the last call, so we always render it.
  8084. + */
  8085. + const guint64 current_ms = g_get_monotonic_time () / 1000;
  8086. + if (percentage != 100)
  8087. + {
  8088. + const guint64 diff_ms = current_ms - last_update_ms;
  8089. + if (glnx_stdout_is_tty ())
  8090. + {
  8091. + if (diff_ms < (1000/MAX_TTY_UPDATE_HZ))
  8092. + return;
  8093. + }
  8094. + else
  8095. + {
  8096. + if (diff_ms < (1000/MAX_NONTTY_UPDATE_HZ))
  8097. + return;
  8098. + }
  8099. + }
  8100. + last_update_ms = current_ms;
  8101. +
  8102. + static const char equals[] = "====================";
  8103. + const guint n_equals = sizeof (equals) - 1;
  8104. + static const char spaces[] = " ";
  8105. + const guint n_spaces = sizeof (spaces) - 1;
  8106. + const guint ncolumns = glnx_console_columns ();
  8107. + const guint bar_min = 10;
  8108. +
  8109. + if (text && !*text)
  8110. + text = NULL;
  8111. +
  8112. + const guint input_textlen = text ? strlen (text) : 0;
  8113. +
  8114. + if (!glnx_stdout_is_tty ())
  8115. + {
  8116. + if (text)
  8117. + fprintf (stdout, "%s", text);
  8118. + if (percentage != -1)
  8119. + {
  8120. + if (text)
  8121. + fputc (' ', stdout);
  8122. + fprintf (stdout, "%u%%", percentage);
  8123. + }
  8124. + fputc ('\n', stdout);
  8125. + fflush (stdout);
  8126. + return;
  8127. + }
  8128. +
  8129. + if (ncolumns < bar_min)
  8130. + return; /* TODO: spinner */
  8131. +
  8132. + /* Restore cursor */
  8133. + { const char beginbuf[2] = { 0x1B, 0x38 };
  8134. + (void) fwrite (beginbuf, 1, sizeof (beginbuf), stdout);
  8135. + }
  8136. +
  8137. + if (percentage == -1)
  8138. + {
  8139. + if (text != NULL)
  8140. + fwrite (text, 1, input_textlen, stdout);
  8141. +
  8142. + /* Overwrite remaining space, if any */
  8143. + if (ncolumns > input_textlen)
  8144. + printpad (spaces, n_spaces, ncolumns - input_textlen);
  8145. + }
  8146. + else
  8147. + {
  8148. + const guint textlen = MIN (input_textlen, ncolumns - bar_min);
  8149. + const guint barlen = MIN (MAX_PROGRESSBAR_COLUMNS, ncolumns - (textlen + 1));
  8150. +
  8151. + if (textlen > 0)
  8152. + {
  8153. + fwrite (text, 1, textlen, stdout);
  8154. + fputc (' ', stdout);
  8155. + }
  8156. +
  8157. + {
  8158. + const guint nbraces = 2;
  8159. + const guint textpercent_len = 5;
  8160. + const guint bar_internal_len = barlen - nbraces - textpercent_len;
  8161. + const guint eqlen = bar_internal_len * (percentage / 100.0);
  8162. + const guint spacelen = bar_internal_len - eqlen;
  8163. +
  8164. + fputc ('[', stdout);
  8165. + printpad (equals, n_equals, eqlen);
  8166. + printpad (spaces, n_spaces, spacelen);
  8167. + fputc (']', stdout);
  8168. + fprintf (stdout, " %3d%%", percentage);
  8169. + }
  8170. + }
  8171. +
  8172. + fflush (stdout);
  8173. +}
  8174. +
  8175. +/**
  8176. + * glnx_console_progress_text_percent:
  8177. + * @text: Show this text before the progress bar
  8178. + * @percentage: An integer in the range of 0 to 100
  8179. + *
  8180. + * On a tty, print to the console @text followed by an ASCII art
  8181. + * progress bar whose percentage is @percentage. If stdout is not a
  8182. + * tty, a more basic line by line change will be printed.
  8183. + *
  8184. + * You must have called glnx_console_lock() before invoking this
  8185. + * function.
  8186. + *
  8187. + */
  8188. +void
  8189. +glnx_console_progress_text_percent (const char *text,
  8190. + guint percentage)
  8191. +{
  8192. + g_return_if_fail (percentage <= 100);
  8193. +
  8194. + text_percent_internal (text, percentage);
  8195. +}
  8196. +
  8197. +/**
  8198. + * glnx_console_progress_n_items:
  8199. + * @text: Show this text before the progress bar
  8200. + * @current: An integer for how many items have been processed
  8201. + * @total: An integer for how many items there are total
  8202. + *
  8203. + * On a tty, print to the console @text followed by [@current/@total],
  8204. + * then an ASCII art progress bar, like glnx_console_progress_text_percent().
  8205. + *
  8206. + * You must have called glnx_console_lock() before invoking this
  8207. + * function.
  8208. + */
  8209. +void
  8210. +glnx_console_progress_n_items (const char *text,
  8211. + guint current,
  8212. + guint total)
  8213. +{
  8214. + g_return_if_fail (current <= total);
  8215. + g_return_if_fail (total > 0);
  8216. +
  8217. + g_autofree char *newtext = g_strdup_printf ("%s (%u/%u)", text, current, total);
  8218. + /* Special case current == total to ensure we end at 100% */
  8219. + int percentage = (current == total) ? 100 : (((double)current) / total * 100);
  8220. + glnx_console_progress_text_percent (newtext, percentage);
  8221. +}
  8222. +
  8223. +void
  8224. +glnx_console_text (const char *text)
  8225. +{
  8226. + text_percent_internal (text, -1);
  8227. +}
  8228. +
  8229. +/**
  8230. + * glnx_console_unlock:
  8231. + *
  8232. + * Print a newline, and reset all cached console progress state.
  8233. + *
  8234. + * This function does nothing if stdout is not a tty.
  8235. + */
  8236. +void
  8237. +glnx_console_unlock (GLnxConsoleRef *console)
  8238. +{
  8239. + g_return_if_fail (locked);
  8240. + g_return_if_fail (console->locked);
  8241. +
  8242. + if (console->is_tty)
  8243. + fputc ('\n', stdout);
  8244. +
  8245. + locked = console->locked = FALSE;
  8246. +}
  8247. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-console.h flatpak-1.0.0/libglnx/glnx-console.h
  8248. --- flatpak-1.0.0.orig/libglnx/glnx-console.h 1970-01-01 02:00:00.000000000 +0200
  8249. +++ flatpak-1.0.0/libglnx/glnx-console.h 2018-05-26 00:50:25.433037228 +0300
  8250. @@ -0,0 +1,61 @@
  8251. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  8252. + *
  8253. + * Copyright (C) 2013,2014,2015 Colin Walters <walters@verbum.org>
  8254. + *
  8255. + * This program is free software: you can redistribute it and/or modify
  8256. + * it under the terms of the GNU Lesser General Public License as published
  8257. + * by the Free Software Foundation; either version 2 of the licence or (at
  8258. + * your option) any later version.
  8259. + *
  8260. + * This library is distributed in the hope that it will be useful,
  8261. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8262. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  8263. + * Lesser General Public License for more details.
  8264. + *
  8265. + * You should have received a copy of the GNU Lesser General
  8266. + * Public License along with this library; if not, write to the
  8267. + * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  8268. + * Boston, MA 02111-1307, USA.
  8269. + */
  8270. +
  8271. +#pragma once
  8272. +
  8273. +#include <glnx-backport-autocleanups.h>
  8274. +
  8275. +G_BEGIN_DECLS
  8276. +
  8277. +struct GLnxConsoleRef {
  8278. + gboolean locked;
  8279. + gboolean is_tty;
  8280. +};
  8281. +
  8282. +typedef struct GLnxConsoleRef GLnxConsoleRef;
  8283. +
  8284. +gboolean glnx_stdout_is_tty (void);
  8285. +
  8286. +void glnx_console_lock (GLnxConsoleRef *ref);
  8287. +
  8288. +void glnx_console_text (const char *text);
  8289. +
  8290. +void glnx_console_progress_text_percent (const char *text,
  8291. + guint percentage);
  8292. +
  8293. +void glnx_console_progress_n_items (const char *text,
  8294. + guint current,
  8295. + guint total);
  8296. +
  8297. +void glnx_console_unlock (GLnxConsoleRef *ref);
  8298. +
  8299. +guint glnx_console_lines (void);
  8300. +
  8301. +guint glnx_console_columns (void);
  8302. +
  8303. +static inline void
  8304. +glnx_console_ref_cleanup (GLnxConsoleRef *p)
  8305. +{
  8306. + if (p->locked)
  8307. + glnx_console_unlock (p);
  8308. +}
  8309. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxConsoleRef, glnx_console_ref_cleanup)
  8310. +
  8311. +G_END_DECLS
  8312. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-dirfd.c flatpak-1.0.0/libglnx/glnx-dirfd.c
  8313. --- flatpak-1.0.0.orig/libglnx/glnx-dirfd.c 1970-01-01 02:00:00.000000000 +0200
  8314. +++ flatpak-1.0.0/libglnx/glnx-dirfd.c 2018-05-26 00:50:25.433037228 +0300
  8315. @@ -0,0 +1,425 @@
  8316. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  8317. + *
  8318. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  8319. + *
  8320. + * This library is free software; you can redistribute it and/or
  8321. + * modify it under the terms of the GNU Lesser General Public
  8322. + * License as published by the Free Software Foundation; either
  8323. + * version 2 of the License, or (at your option) any later version.
  8324. + *
  8325. + * This library is distributed in the hope that it will be useful,
  8326. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8327. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  8328. + * Lesser General Public License for more details.
  8329. + *
  8330. + * You should have received a copy of the GNU Lesser General Public
  8331. + * License along with this library; if not, write to the
  8332. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  8333. + * Boston, MA 02111-1307, USA.
  8334. + */
  8335. +
  8336. +#include "config.h"
  8337. +
  8338. +#include <string.h>
  8339. +
  8340. +#include <glnx-dirfd.h>
  8341. +#include <glnx-fdio.h>
  8342. +#include <glnx-errors.h>
  8343. +#include <glnx-local-alloc.h>
  8344. +#include <glnx-shutil.h>
  8345. +
  8346. +/**
  8347. + * glnx_opendirat_with_errno:
  8348. + * @dfd: File descriptor for origin directory
  8349. + * @name: Pathname, relative to @dfd
  8350. + * @follow: Whether or not to follow symbolic links
  8351. + *
  8352. + * Use openat() to open a directory, using a standard set of flags.
  8353. + * This function sets errno.
  8354. + */
  8355. +int
  8356. +glnx_opendirat_with_errno (int dfd,
  8357. + const char *path,
  8358. + gboolean follow)
  8359. +{
  8360. + int flags = O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOCTTY;
  8361. + if (!follow)
  8362. + flags |= O_NOFOLLOW;
  8363. +
  8364. + dfd = glnx_dirfd_canonicalize (dfd);
  8365. +
  8366. + return openat (dfd, path, flags);
  8367. +}
  8368. +
  8369. +/**
  8370. + * glnx_opendirat:
  8371. + * @dfd: File descriptor for origin directory
  8372. + * @path: Pathname, relative to @dfd
  8373. + * @follow: Whether or not to follow symbolic links
  8374. + * @error: Error
  8375. + *
  8376. + * Use openat() to open a directory, using a standard set of flags.
  8377. + */
  8378. +gboolean
  8379. +glnx_opendirat (int dfd,
  8380. + const char *path,
  8381. + gboolean follow,
  8382. + int *out_fd,
  8383. + GError **error)
  8384. +{
  8385. + int ret = glnx_opendirat_with_errno (dfd, path, follow);
  8386. + if (ret == -1)
  8387. + return glnx_throw_errno_prefix (error, "opendir(%s)", path);
  8388. + *out_fd = ret;
  8389. + return TRUE;
  8390. +}
  8391. +
  8392. +struct GLnxRealDirfdIterator
  8393. +{
  8394. + gboolean initialized;
  8395. + int fd;
  8396. + DIR *d;
  8397. +};
  8398. +typedef struct GLnxRealDirfdIterator GLnxRealDirfdIterator;
  8399. +
  8400. +/**
  8401. + * glnx_dirfd_iterator_init_at:
  8402. + * @dfd: File descriptor, may be AT_FDCWD or -1
  8403. + * @path: Path, may be relative to @dfd
  8404. + * @follow: If %TRUE and the last component of @path is a symlink, follow it
  8405. + * @out_dfd_iter: (out caller-allocates): A directory iterator, will be initialized
  8406. + * @error: Error
  8407. + *
  8408. + * Initialize @out_dfd_iter from @dfd and @path.
  8409. + */
  8410. +gboolean
  8411. +glnx_dirfd_iterator_init_at (int dfd,
  8412. + const char *path,
  8413. + gboolean follow,
  8414. + GLnxDirFdIterator *out_dfd_iter,
  8415. + GError **error)
  8416. +{
  8417. + glnx_autofd int fd = -1;
  8418. + if (!glnx_opendirat (dfd, path, follow, &fd, error))
  8419. + return FALSE;
  8420. +
  8421. + if (!glnx_dirfd_iterator_init_take_fd (&fd, out_dfd_iter, error))
  8422. + return FALSE;
  8423. +
  8424. + return TRUE;
  8425. +}
  8426. +
  8427. +/**
  8428. + * glnx_dirfd_iterator_init_take_fd:
  8429. + * @dfd: File descriptor - ownership is taken, and the value is set to -1
  8430. + * @dfd_iter: A directory iterator
  8431. + * @error: Error
  8432. + *
  8433. + * Steal ownership of @dfd, using it to initialize @dfd_iter for
  8434. + * iteration.
  8435. + */
  8436. +gboolean
  8437. +glnx_dirfd_iterator_init_take_fd (int *dfd,
  8438. + GLnxDirFdIterator *dfd_iter,
  8439. + GError **error)
  8440. +{
  8441. + GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
  8442. + DIR *d = fdopendir (*dfd);
  8443. + if (!d)
  8444. + return glnx_throw_errno_prefix (error, "fdopendir");
  8445. +
  8446. + real_dfd_iter->fd = glnx_steal_fd (dfd);
  8447. + real_dfd_iter->d = d;
  8448. + real_dfd_iter->initialized = TRUE;
  8449. +
  8450. + return TRUE;
  8451. +}
  8452. +
  8453. +/**
  8454. + * glnx_dirfd_iterator_next_dent:
  8455. + * @dfd_iter: A directory iterator
  8456. + * @out_dent: (out) (transfer none): Pointer to dirent; do not free
  8457. + * @cancellable: Cancellable
  8458. + * @error: Error
  8459. + *
  8460. + * Read the next value from @dfd_iter, causing @out_dent to be
  8461. + * updated. If end of stream is reached, @out_dent will be set
  8462. + * to %NULL, and %TRUE will be returned.
  8463. + */
  8464. +gboolean
  8465. +glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
  8466. + struct dirent **out_dent,
  8467. + GCancellable *cancellable,
  8468. + GError **error)
  8469. +{
  8470. + GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
  8471. +
  8472. + g_return_val_if_fail (out_dent, FALSE);
  8473. + g_return_val_if_fail (dfd_iter->initialized, FALSE);
  8474. +
  8475. + if (g_cancellable_set_error_if_cancelled (cancellable, error))
  8476. + return FALSE;
  8477. +
  8478. + do
  8479. + {
  8480. + errno = 0;
  8481. + *out_dent = readdir (real_dfd_iter->d);
  8482. + if (*out_dent == NULL && errno != 0)
  8483. + return glnx_throw_errno_prefix (error, "readdir");
  8484. + } while (*out_dent &&
  8485. + (strcmp ((*out_dent)->d_name, ".") == 0 ||
  8486. + strcmp ((*out_dent)->d_name, "..") == 0));
  8487. +
  8488. + return TRUE;
  8489. +}
  8490. +
  8491. +/**
  8492. + * glnx_dirfd_iterator_next_dent_ensure_dtype:
  8493. + * @dfd_iter: A directory iterator
  8494. + * @out_dent: (out) (transfer none): Pointer to dirent; do not free
  8495. + * @cancellable: Cancellable
  8496. + * @error: Error
  8497. + *
  8498. + * A variant of @glnx_dirfd_iterator_next_dent, which will ensure the
  8499. + * `dent->d_type` member is filled in by calling `fstatat`
  8500. + * automatically if the underlying filesystem type sets `DT_UNKNOWN`.
  8501. + */
  8502. +gboolean
  8503. +glnx_dirfd_iterator_next_dent_ensure_dtype (GLnxDirFdIterator *dfd_iter,
  8504. + struct dirent **out_dent,
  8505. + GCancellable *cancellable,
  8506. + GError **error)
  8507. +{
  8508. + g_return_val_if_fail (out_dent, FALSE);
  8509. +
  8510. + if (!glnx_dirfd_iterator_next_dent (dfd_iter, out_dent, cancellable, error))
  8511. + return FALSE;
  8512. +
  8513. + struct dirent *ret_dent = *out_dent;
  8514. + if (ret_dent)
  8515. + {
  8516. +
  8517. + if (ret_dent->d_type == DT_UNKNOWN)
  8518. + {
  8519. + struct stat stbuf;
  8520. + if (!glnx_fstatat (dfd_iter->fd, ret_dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
  8521. + return FALSE;
  8522. + ret_dent->d_type = IFTODT (stbuf.st_mode);
  8523. + }
  8524. + }
  8525. +
  8526. + return TRUE;
  8527. +}
  8528. +
  8529. +/**
  8530. + * glnx_dirfd_iterator_clear:
  8531. + * @dfd_iter: Iterator, will be de-initialized
  8532. + *
  8533. + * Unset @dfd_iter, freeing any resources. If @dfd_iter is not
  8534. + * initialized, do nothing.
  8535. + */
  8536. +void
  8537. +glnx_dirfd_iterator_clear (GLnxDirFdIterator *dfd_iter)
  8538. +{
  8539. + GLnxRealDirfdIterator *real_dfd_iter = (GLnxRealDirfdIterator*) dfd_iter;
  8540. + /* fd is owned by dfd_iter */
  8541. + if (!real_dfd_iter->initialized)
  8542. + return;
  8543. + (void) closedir (real_dfd_iter->d);
  8544. + real_dfd_iter->initialized = FALSE;
  8545. +}
  8546. +
  8547. +/**
  8548. + * glnx_fdrel_abspath:
  8549. + * @dfd: Directory fd
  8550. + * @path: Path
  8551. + *
  8552. + * Turn a fd-relative pair into something that can be used for legacy
  8553. + * APIs expecting absolute paths.
  8554. + *
  8555. + * This is Linux specific, and only valid inside this process (unless
  8556. + * you set up the child process to have the exact same fd number, but
  8557. + * don't try that).
  8558. + */
  8559. +char *
  8560. +glnx_fdrel_abspath (int dfd,
  8561. + const char *path)
  8562. +{
  8563. + dfd = glnx_dirfd_canonicalize (dfd);
  8564. + if (dfd == AT_FDCWD)
  8565. + return g_strdup (path);
  8566. + return g_strdup_printf ("/proc/self/fd/%d/%s", dfd, path);
  8567. +}
  8568. +
  8569. +/**
  8570. + * glnx_gen_temp_name:
  8571. + * @tmpl: (type filename): template directory name, the last 6 characters will be replaced
  8572. + *
  8573. + * Replace the last 6 characters of @tmpl with random ASCII. You must
  8574. + * use this in combination with a mechanism to ensure race-free file
  8575. + * creation such as `O_EXCL`.
  8576. + */
  8577. +void
  8578. +glnx_gen_temp_name (gchar *tmpl)
  8579. +{
  8580. + g_return_if_fail (tmpl != NULL);
  8581. + const size_t len = strlen (tmpl);
  8582. + g_return_if_fail (len >= 6);
  8583. +
  8584. + static const char letters[] =
  8585. + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  8586. + static const int NLETTERS = sizeof (letters) - 1;
  8587. +
  8588. + char *XXXXXX = tmpl + (len - 6);
  8589. + for (int i = 0; i < 6; i++)
  8590. + XXXXXX[i] = letters[g_random_int_range(0, NLETTERS)];
  8591. +}
  8592. +
  8593. +/**
  8594. + * glnx_mkdtempat:
  8595. + * @dfd: Directory fd
  8596. + * @tmpl: (type filename): Initial template directory name, last 6 characters will be replaced
  8597. + * @mode: permissions with which to create the temporary directory
  8598. + * @out_tmpdir: (out caller-allocates): Initialized tempdir structure
  8599. + * @error: Error
  8600. + *
  8601. + * Somewhat similar to g_mkdtemp_full(), but fd-relative, and returns a
  8602. + * structure that uses autocleanups. Note that the supplied @dfd lifetime
  8603. + * must match or exceed that of @out_tmpdir in order to remove the directory.
  8604. + */
  8605. +gboolean
  8606. +glnx_mkdtempat (int dfd, const char *tmpl, int mode,
  8607. + GLnxTmpDir *out_tmpdir, GError **error)
  8608. +{
  8609. + g_return_val_if_fail (tmpl != NULL, FALSE);
  8610. + g_return_val_if_fail (out_tmpdir != NULL, FALSE);
  8611. + g_return_val_if_fail (!out_tmpdir->initialized, FALSE);
  8612. +
  8613. + dfd = glnx_dirfd_canonicalize (dfd);
  8614. +
  8615. + g_autofree char *path = g_strdup (tmpl);
  8616. + for (int count = 0; count < 100; count++)
  8617. + {
  8618. + glnx_gen_temp_name (path);
  8619. +
  8620. + /* Ideally we could use openat(O_DIRECTORY | O_CREAT | O_EXCL) here
  8621. + * to create and open the directory atomically, but that’s not supported by
  8622. + * current kernel versions: http://www.openwall.com/lists/oss-security/2014/11/26/14
  8623. + * (Tested on kernel 4.10.10-200.fc25.x86_64). For the moment, accept a
  8624. + * TOCTTOU race here. */
  8625. + if (mkdirat (dfd, path, mode) == -1)
  8626. + {
  8627. + if (errno == EEXIST)
  8628. + continue;
  8629. +
  8630. + /* Any other error will apply also to other names we might
  8631. + * try, and there are 2^32 or so of them, so give up now.
  8632. + */
  8633. + return glnx_throw_errno_prefix (error, "mkdirat");
  8634. + }
  8635. +
  8636. + /* And open it */
  8637. + glnx_autofd int ret_dfd = -1;
  8638. + if (!glnx_opendirat (dfd, path, FALSE, &ret_dfd, error))
  8639. + {
  8640. + /* If we fail to open, let's try to clean up */
  8641. + (void)unlinkat (dfd, path, AT_REMOVEDIR);
  8642. + return FALSE;
  8643. + }
  8644. +
  8645. + /* Return the initialized directory struct */
  8646. + out_tmpdir->initialized = TRUE;
  8647. + out_tmpdir->src_dfd = dfd; /* referenced; see above docs */
  8648. + out_tmpdir->fd = glnx_steal_fd (&ret_dfd);
  8649. + out_tmpdir->path = g_steal_pointer (&path);
  8650. + return TRUE;
  8651. + }
  8652. +
  8653. + /* Failure */
  8654. + g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
  8655. + "glnx_mkdtempat ran out of combinations to try");
  8656. + return FALSE;
  8657. +}
  8658. +
  8659. +/**
  8660. + * glnx_mkdtemp:
  8661. + * @tmpl: (type filename): Source template directory name, last 6 characters will be replaced
  8662. + * @mode: permissions to create the temporary directory with
  8663. + * @out_tmpdir: (out caller-allocates): Return location for tmpdir data
  8664. + * @error: Return location for a #GError, or %NULL
  8665. + *
  8666. + * Similar to glnx_mkdtempat(), but will use g_get_tmp_dir() as the parent
  8667. + * directory to @tmpl.
  8668. + *
  8669. + * Returns: %TRUE on success, %FALSE otherwise
  8670. + * Since: UNRELEASED
  8671. + */
  8672. +gboolean
  8673. +glnx_mkdtemp (const gchar *tmpl,
  8674. + int mode,
  8675. + GLnxTmpDir *out_tmpdir,
  8676. + GError **error)
  8677. +{
  8678. + g_autofree char *path = g_build_filename (g_get_tmp_dir (), tmpl, NULL);
  8679. + return glnx_mkdtempat (AT_FDCWD, path, mode,
  8680. + out_tmpdir, error);
  8681. +}
  8682. +
  8683. +static gboolean
  8684. +_glnx_tmpdir_free (GLnxTmpDir *tmpd,
  8685. + gboolean delete_dir,
  8686. + GCancellable *cancellable,
  8687. + GError **error)
  8688. +{
  8689. + /* Support being passed NULL so we work nicely in a GPtrArray */
  8690. + if (!(tmpd && tmpd->initialized))
  8691. + return TRUE;
  8692. + g_assert_cmpint (tmpd->fd, !=, -1);
  8693. + glnx_close_fd (&tmpd->fd);
  8694. + g_assert (tmpd->path);
  8695. + g_assert_cmpint (tmpd->src_dfd, !=, -1);
  8696. + g_autofree char *path = tmpd->path; /* Take ownership */
  8697. + tmpd->initialized = FALSE;
  8698. + if (delete_dir)
  8699. + {
  8700. + if (!glnx_shutil_rm_rf_at (tmpd->src_dfd, path, cancellable, error))
  8701. + return FALSE;
  8702. + }
  8703. + return TRUE;
  8704. +}
  8705. +
  8706. +/**
  8707. + * glnx_tmpdir_delete:
  8708. + * @tmpf: Temporary dir
  8709. + * @cancellable: Cancellable
  8710. + * @error: Error
  8711. + *
  8712. + * Deallocate a tmpdir, closing the fd and recursively deleting the path. This
  8713. + * is normally called indirectly via glnx_tmpdir_cleanup() by the autocleanup
  8714. + * attribute, but you can also invoke this directly.
  8715. + *
  8716. + * If an error occurs while deleting the filesystem path, @tmpf will still have
  8717. + * been deallocated and should not be reused.
  8718. + *
  8719. + * See also `glnx_tmpdir_unset` to avoid deleting the path.
  8720. + */
  8721. +gboolean
  8722. +glnx_tmpdir_delete (GLnxTmpDir *tmpf, GCancellable *cancellable, GError **error)
  8723. +{
  8724. + return _glnx_tmpdir_free (tmpf, TRUE, cancellable, error);
  8725. +}
  8726. +
  8727. +/**
  8728. + * glnx_tmpdir_unset:
  8729. + * @tmpf: Temporary dir
  8730. + * @cancellable: Cancellable
  8731. + * @error: Error
  8732. + *
  8733. + * Deallocate a tmpdir, but do not delete the filesystem path. See also
  8734. + * `glnx_tmpdir_delete()`.
  8735. + */
  8736. +void
  8737. +glnx_tmpdir_unset (GLnxTmpDir *tmpf)
  8738. +{
  8739. + (void) _glnx_tmpdir_free (tmpf, FALSE, NULL, NULL);
  8740. +}
  8741. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-dirfd.h flatpak-1.0.0/libglnx/glnx-dirfd.h
  8742. --- flatpak-1.0.0.orig/libglnx/glnx-dirfd.h 1970-01-01 02:00:00.000000000 +0200
  8743. +++ flatpak-1.0.0/libglnx/glnx-dirfd.h 2018-02-03 21:26:06.308233341 +0300
  8744. @@ -0,0 +1,137 @@
  8745. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  8746. + *
  8747. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  8748. + *
  8749. + * This library is free software; you can redistribute it and/or
  8750. + * modify it under the terms of the GNU Lesser General Public
  8751. + * License as published by the Free Software Foundation; either
  8752. + * version 2 of the License, or (at your option) any later version.
  8753. + *
  8754. + * This library is distributed in the hope that it will be useful,
  8755. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8756. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  8757. + * Lesser General Public License for more details.
  8758. + *
  8759. + * You should have received a copy of the GNU Lesser General Public
  8760. + * License along with this library; if not, write to the
  8761. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  8762. + * Boston, MA 02111-1307, USA.
  8763. + */
  8764. +
  8765. +#pragma once
  8766. +
  8767. +#include <glnx-backport-autocleanups.h>
  8768. +#include <glnx-macros.h>
  8769. +#include <glnx-errors.h>
  8770. +#include <limits.h>
  8771. +#include <dirent.h>
  8772. +#include <sys/stat.h>
  8773. +#include <fcntl.h>
  8774. +
  8775. +G_BEGIN_DECLS
  8776. +
  8777. +/**
  8778. + * glnx_dirfd_canonicalize:
  8779. + * @fd: A directory file descriptor
  8780. + *
  8781. + * It's often convenient in programs to use `-1` for "unassigned fd",
  8782. + * and also because gobject-introspection doesn't support `AT_FDCWD`,
  8783. + * libglnx honors `-1` to mean `AT_FDCWD`. This small inline function
  8784. + * canonicalizes `-1 -> AT_FDCWD`.
  8785. + */
  8786. +static inline int
  8787. +glnx_dirfd_canonicalize (int fd)
  8788. +{
  8789. + if (fd == -1)
  8790. + return AT_FDCWD;
  8791. + return fd;
  8792. +}
  8793. +
  8794. +struct GLnxDirFdIterator {
  8795. + gboolean initialized;
  8796. + int fd;
  8797. + gpointer padding_data[4];
  8798. +};
  8799. +
  8800. +typedef struct GLnxDirFdIterator GLnxDirFdIterator;
  8801. +gboolean glnx_dirfd_iterator_init_at (int dfd, const char *path,
  8802. + gboolean follow,
  8803. + GLnxDirFdIterator *dfd_iter, GError **error);
  8804. +gboolean glnx_dirfd_iterator_init_take_fd (int *dfd, GLnxDirFdIterator *dfd_iter, GError **error);
  8805. +gboolean glnx_dirfd_iterator_next_dent (GLnxDirFdIterator *dfd_iter,
  8806. + struct dirent **out_dent,
  8807. + GCancellable *cancellable,
  8808. + GError **error);
  8809. +gboolean glnx_dirfd_iterator_next_dent_ensure_dtype (GLnxDirFdIterator *dfd_iter,
  8810. + struct dirent **out_dent,
  8811. + GCancellable *cancellable,
  8812. + GError **error);
  8813. +void glnx_dirfd_iterator_clear (GLnxDirFdIterator *dfd_iter);
  8814. +
  8815. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxDirFdIterator, glnx_dirfd_iterator_clear)
  8816. +
  8817. +int glnx_opendirat_with_errno (int dfd,
  8818. + const char *path,
  8819. + gboolean follow);
  8820. +
  8821. +gboolean glnx_opendirat (int dfd,
  8822. + const char *path,
  8823. + gboolean follow,
  8824. + int *out_fd,
  8825. + GError **error);
  8826. +
  8827. +char *glnx_fdrel_abspath (int dfd,
  8828. + const char *path);
  8829. +
  8830. +void glnx_gen_temp_name (gchar *tmpl);
  8831. +
  8832. +/**
  8833. + * glnx_ensure_dir:
  8834. + * @dfd: directory fd
  8835. + * @path: Directory path
  8836. + * @mode: Mode
  8837. + * @error: Return location for a #GError, or %NULL
  8838. + *
  8839. + * Wrapper around mkdirat() which adds #GError support, ensures that
  8840. + * it retries on %EINTR, and also ignores `EEXIST`.
  8841. + *
  8842. + * See also `glnx_shutil_mkdir_p_at()` for recursive handling.
  8843. + *
  8844. + * Returns: %TRUE on success, %FALSE otherwise
  8845. + */
  8846. +static inline gboolean
  8847. +glnx_ensure_dir (int dfd,
  8848. + const char *path,
  8849. + mode_t mode,
  8850. + GError **error)
  8851. +{
  8852. + if (TEMP_FAILURE_RETRY (mkdirat (dfd, path, mode)) != 0)
  8853. + {
  8854. + if (G_UNLIKELY (errno != EEXIST))
  8855. + return glnx_throw_errno_prefix (error, "mkdirat(%s)", path);
  8856. + }
  8857. + return TRUE;
  8858. +}
  8859. +
  8860. +typedef struct {
  8861. + gboolean initialized;
  8862. + int src_dfd;
  8863. + int fd;
  8864. + char *path;
  8865. +} GLnxTmpDir;
  8866. +gboolean glnx_tmpdir_delete (GLnxTmpDir *tmpf, GCancellable *cancellable, GError **error);
  8867. +void glnx_tmpdir_unset (GLnxTmpDir *tmpf);
  8868. +static inline void
  8869. +glnx_tmpdir_cleanup (GLnxTmpDir *tmpf)
  8870. +{
  8871. + (void)glnx_tmpdir_delete (tmpf, NULL, NULL);
  8872. +}
  8873. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpDir, glnx_tmpdir_cleanup)
  8874. +
  8875. +gboolean glnx_mkdtempat (int dfd, const char *tmpl, int mode,
  8876. + GLnxTmpDir *out_tmpdir, GError **error);
  8877. +
  8878. +gboolean glnx_mkdtemp (const char *tmpl, int mode,
  8879. + GLnxTmpDir *out_tmpdir, GError **error);
  8880. +
  8881. +G_END_DECLS
  8882. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-errors.c flatpak-1.0.0/libglnx/glnx-errors.c
  8883. --- flatpak-1.0.0.orig/libglnx/glnx-errors.c 1970-01-01 02:00:00.000000000 +0200
  8884. +++ flatpak-1.0.0/libglnx/glnx-errors.c 2018-05-26 00:50:25.433037228 +0300
  8885. @@ -0,0 +1,131 @@
  8886. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  8887. + *
  8888. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  8889. + *
  8890. + * This library is free software; you can redistribute it and/or
  8891. + * modify it under the terms of the GNU Lesser General Public
  8892. + * License as published by the Free Software Foundation; either
  8893. + * version 2 of the License, or (at your option) any later version.
  8894. + *
  8895. + * This library is distributed in the hope that it will be useful,
  8896. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8897. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  8898. + * Lesser General Public License for more details.
  8899. + *
  8900. + * You should have received a copy of the GNU Lesser General Public
  8901. + * License along with this library; if not, write to the
  8902. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  8903. + * Boston, MA 02111-1307, USA.
  8904. + */
  8905. +
  8906. +#include "config.h"
  8907. +
  8908. +#include <glnx-backport-autocleanups.h>
  8909. +#include <glnx-errors.h>
  8910. +
  8911. +/* Set @error with G_IO_ERROR/G_IO_ERROR_FAILED.
  8912. + *
  8913. + * This function returns %FALSE so it can be used conveniently in a single
  8914. + * statement:
  8915. + *
  8916. + * ```
  8917. + * if (strcmp (foo, "somevalue") != 0)
  8918. + * return glnx_throw (error, "key must be somevalue, not '%s'", foo);
  8919. + * ```
  8920. + */
  8921. +gboolean
  8922. +glnx_throw (GError **error,
  8923. + const char *fmt,
  8924. + ...)
  8925. +{
  8926. + if (error == NULL)
  8927. + return FALSE;
  8928. +
  8929. + va_list args;
  8930. + va_start (args, fmt);
  8931. + GError *new = g_error_new_valist (G_IO_ERROR, G_IO_ERROR_FAILED, fmt, args);
  8932. + va_end (args);
  8933. + g_propagate_error (error, g_steal_pointer (&new));
  8934. + return FALSE;
  8935. +}
  8936. +
  8937. +void
  8938. +glnx_real_set_prefix_error_va (GError *error,
  8939. + const char *format,
  8940. + va_list args)
  8941. +{
  8942. + if (error == NULL)
  8943. + return;
  8944. +
  8945. + g_autofree char *old_msg = g_steal_pointer (&error->message);
  8946. + g_autoptr(GString) buf = g_string_new ("");
  8947. + g_string_append_vprintf (buf, format, args);
  8948. + g_string_append (buf, ": ");
  8949. + g_string_append (buf, old_msg);
  8950. + error->message = g_string_free (g_steal_pointer (&buf), FALSE);
  8951. +}
  8952. +
  8953. +/* Prepend to @error's message by `$prefix: ` where `$prefix` is computed via
  8954. + * printf @fmt. Returns %FALSE so it can be used conveniently in a single
  8955. + * statement:
  8956. + *
  8957. + * ```
  8958. + * if (!function_that_fails (s, error))
  8959. + * return glnx_throw_prefix (error, "while handling '%s'", s);
  8960. + * ```
  8961. + * */
  8962. +gboolean
  8963. +glnx_prefix_error (GError **error,
  8964. + const char *fmt,
  8965. + ...)
  8966. +{
  8967. + if (error == NULL)
  8968. + return FALSE;
  8969. +
  8970. + va_list args;
  8971. + va_start (args, fmt);
  8972. + glnx_real_set_prefix_error_va (*error, fmt, args);
  8973. + va_end (args);
  8974. + return FALSE;
  8975. +}
  8976. +
  8977. +void
  8978. +glnx_real_set_prefix_error_from_errno_va (GError **error,
  8979. + gint errsv,
  8980. + const char *format,
  8981. + va_list args)
  8982. +{
  8983. + if (!error)
  8984. + return;
  8985. +
  8986. + g_set_error_literal (error,
  8987. + G_IO_ERROR,
  8988. + g_io_error_from_errno (errsv),
  8989. + g_strerror (errsv));
  8990. + glnx_real_set_prefix_error_va (*error, format, args);
  8991. +}
  8992. +
  8993. +/* Set @error using the value of `$prefix: g_strerror (errno)` where `$prefix`
  8994. + * is computed via printf @fmt.
  8995. + *
  8996. + * This function returns %FALSE so it can be used conveniently in a single
  8997. + * statement:
  8998. + *
  8999. + * ```
  9000. + * return glnx_throw_errno_prefix (error, "unlinking %s", pathname);
  9001. + * ```
  9002. + */
  9003. +gboolean
  9004. +glnx_throw_errno_prefix (GError **error,
  9005. + const char *fmt,
  9006. + ...)
  9007. +{
  9008. + int errsv = errno;
  9009. + va_list args;
  9010. + va_start (args, fmt);
  9011. + glnx_real_set_prefix_error_from_errno_va (error, errsv, fmt, args);
  9012. + va_end (args);
  9013. + /* See comment in glnx_throw_errno() about preserving errno */
  9014. + errno = errsv;
  9015. + return FALSE;
  9016. +}
  9017. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-errors.h flatpak-1.0.0/libglnx/glnx-errors.h
  9018. --- flatpak-1.0.0.orig/libglnx/glnx-errors.h 1970-01-01 02:00:00.000000000 +0200
  9019. +++ flatpak-1.0.0/libglnx/glnx-errors.h 2018-05-26 00:50:25.433037228 +0300
  9020. @@ -0,0 +1,134 @@
  9021. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  9022. + *
  9023. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  9024. + *
  9025. + * This library is free software; you can redistribute it and/or
  9026. + * modify it under the terms of the GNU Lesser General Public
  9027. + * License as published by the Free Software Foundation; either
  9028. + * version 2 of the License, or (at your option) any later version.
  9029. + *
  9030. + * This library is distributed in the hope that it will be useful,
  9031. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9032. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9033. + * Lesser General Public License for more details.
  9034. + *
  9035. + * You should have received a copy of the GNU Lesser General Public
  9036. + * License along with this library; if not, write to the
  9037. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  9038. + * Boston, MA 02111-1307, USA.
  9039. + */
  9040. +
  9041. +#pragma once
  9042. +
  9043. +#include <glnx-backport-autocleanups.h>
  9044. +#include <errno.h>
  9045. +
  9046. +G_BEGIN_DECLS
  9047. +
  9048. +gboolean glnx_throw (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
  9049. +
  9050. +/* Like `glnx_throw ()`, but returns %NULL. */
  9051. +#define glnx_null_throw(error, args...) \
  9052. + ({glnx_throw (error, args); NULL;})
  9053. +
  9054. +/* Implementation detail of glnx_throw_prefix() */
  9055. +void glnx_real_set_prefix_error_va (GError *error,
  9056. + const char *format,
  9057. + va_list args) G_GNUC_PRINTF (2,0);
  9058. +
  9059. +gboolean glnx_prefix_error (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
  9060. +
  9061. +/* Like `glnx_prefix_error ()`, but returns %NULL. */
  9062. +#define glnx_prefix_error_null(error, args...) \
  9063. + ({glnx_prefix_error (error, args); NULL;})
  9064. +
  9065. +/**
  9066. + * GLNX_AUTO_PREFIX_ERROR:
  9067. + *
  9068. + * An autocleanup-based macro to automatically call `g_prefix_error()` (also with a colon+space `: `)
  9069. + * when it goes out of scope. This is useful when one wants error strings built up by the callee
  9070. + * function, not all callers.
  9071. + *
  9072. + * ```
  9073. + * gboolean start_http_request (..., GError **error)
  9074. + * {
  9075. + * GLNX_AUTO_PREFIX_ERROR ("HTTP request", error)
  9076. + *
  9077. + * if (!libhttp_request_start (..., error))
  9078. + * return FALSE;
  9079. + * ...
  9080. + * return TRUE;
  9081. + * ```
  9082. + */
  9083. +typedef struct {
  9084. + const char *prefix;
  9085. + GError **error;
  9086. +} GLnxAutoErrorPrefix;
  9087. +static inline void
  9088. +glnx_cleanup_auto_prefix_error (GLnxAutoErrorPrefix *prefix)
  9089. +{
  9090. + if (prefix->error && *(prefix->error))
  9091. + g_prefix_error (prefix->error, "%s: ", prefix->prefix);
  9092. +}
  9093. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxAutoErrorPrefix, glnx_cleanup_auto_prefix_error)
  9094. +#define GLNX_AUTO_PREFIX_ERROR(text, error) \
  9095. + G_GNUC_UNUSED g_auto(GLnxAutoErrorPrefix) _GLNX_MAKE_ANONYMOUS(_glnxautoprefixerror_) = { text, error }
  9096. +
  9097. +/* Set @error using the value of `g_strerror (errno)`.
  9098. + *
  9099. + * This function returns %FALSE so it can be used conveniently in a single
  9100. + * statement:
  9101. + *
  9102. + * ```
  9103. + * if (unlinkat (fd, somepathname) < 0)
  9104. + * return glnx_throw_errno (error);
  9105. + * ```
  9106. + */
  9107. +static inline gboolean
  9108. +glnx_throw_errno (GError **error)
  9109. +{
  9110. + /* Save the value of errno, in case one of the
  9111. + * intermediate function calls happens to set it.
  9112. + */
  9113. + int errsv = errno;
  9114. + g_set_error_literal (error, G_IO_ERROR,
  9115. + g_io_error_from_errno (errsv),
  9116. + g_strerror (errsv));
  9117. + /* We also restore the value of errno, since that's
  9118. + * what was done in a long-ago libgsystem commit
  9119. + * https://git.gnome.org/browse/libgsystem/commit/?id=ed106741f7a0596dc8b960b31fdae671d31d666d
  9120. + * but I certainly can't remember now why I did that.
  9121. + */
  9122. + errno = errsv;
  9123. + return FALSE;
  9124. +}
  9125. +
  9126. +/* Like glnx_throw_errno(), but yields a NULL pointer. */
  9127. +#define glnx_null_throw_errno(error) \
  9128. + ({glnx_throw_errno (error); NULL;})
  9129. +
  9130. +/* Implementation detail of glnx_throw_errno_prefix() */
  9131. +void glnx_real_set_prefix_error_from_errno_va (GError **error,
  9132. + gint errsv,
  9133. + const char *format,
  9134. + va_list args) G_GNUC_PRINTF (3,0);
  9135. +
  9136. +gboolean glnx_throw_errno_prefix (GError **error, const char *fmt, ...) G_GNUC_PRINTF (2,3);
  9137. +
  9138. +/* Like glnx_throw_errno_prefix(), but yields a NULL pointer. */
  9139. +#define glnx_null_throw_errno_prefix(error, args...) \
  9140. + ({glnx_throw_errno_prefix (error, args); NULL;})
  9141. +
  9142. +/* BEGIN LEGACY APIS */
  9143. +
  9144. +#define glnx_set_error_from_errno(error) \
  9145. + do { \
  9146. + glnx_throw_errno (error); \
  9147. + } while (0);
  9148. +
  9149. +#define glnx_set_prefix_error_from_errno(error, format, args...) \
  9150. + do { \
  9151. + glnx_throw_errno_prefix (error, format, args); \
  9152. + } while (0);
  9153. +
  9154. +G_END_DECLS
  9155. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-fdio.c flatpak-1.0.0/libglnx/glnx-fdio.c
  9156. --- flatpak-1.0.0.orig/libglnx/glnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
  9157. +++ flatpak-1.0.0/libglnx/glnx-fdio.c 2018-05-26 00:50:25.434037228 +0300
  9158. @@ -0,0 +1,1106 @@
  9159. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  9160. + *
  9161. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  9162. + *
  9163. + * Portions derived from systemd:
  9164. + * Copyright 2010 Lennart Poettering
  9165. + *
  9166. + * This library is free software; you can redistribute it and/or
  9167. + * modify it under the terms of the GNU Lesser General Public
  9168. + * License as published by the Free Software Foundation; either
  9169. + * version 2 of the License, or (at your option) any later version.
  9170. + *
  9171. + * This library is distributed in the hope that it will be useful,
  9172. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9173. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  9174. + * Lesser General Public License for more details.
  9175. + *
  9176. + * You should have received a copy of the GNU Lesser General Public
  9177. + * License along with this library; if not, write to the
  9178. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  9179. + * Boston, MA 02111-1307, USA.
  9180. + */
  9181. +
  9182. +#include "config.h"
  9183. +
  9184. +#include <string.h>
  9185. +#include <stdio.h>
  9186. +#include <stdlib.h>
  9187. +#include <stdint.h>
  9188. +#include <stdbool.h>
  9189. +#include <sys/ioctl.h>
  9190. +#include <sys/sendfile.h>
  9191. +#include <errno.h>
  9192. +
  9193. +#include <glnx-fdio.h>
  9194. +#include <glnx-dirfd.h>
  9195. +#include <glnx-errors.h>
  9196. +#include <glnx-xattrs.h>
  9197. +#include <glnx-backport-autoptr.h>
  9198. +#include <glnx-local-alloc.h>
  9199. +#include <glnx-missing.h>
  9200. +
  9201. +/* The standardized version of BTRFS_IOC_CLONE */
  9202. +#ifndef FICLONE
  9203. +#define FICLONE _IOW(0x94, 9, int)
  9204. +#endif
  9205. +
  9206. +/* Returns the number of chars needed to format variables of the
  9207. + * specified type as a decimal string. Adds in extra space for a
  9208. + * negative '-' prefix (hence works correctly on signed
  9209. + * types). Includes space for the trailing NUL. */
  9210. +#define DECIMAL_STR_MAX(type) \
  9211. + (2+(sizeof(type) <= 1 ? 3 : \
  9212. + sizeof(type) <= 2 ? 5 : \
  9213. + sizeof(type) <= 4 ? 10 : \
  9214. + sizeof(type) <= 8 ? 20 : sizeof(int[-2*(sizeof(type) > 8)])))
  9215. +
  9216. +gboolean
  9217. +glnx_stdio_file_flush (FILE *f, GError **error)
  9218. +{
  9219. + if (fflush (f) != 0)
  9220. + return glnx_throw_errno_prefix (error, "fflush");
  9221. + if (ferror (f) != 0)
  9222. + return glnx_throw_errno_prefix (error, "ferror");
  9223. + return TRUE;
  9224. +}
  9225. +
  9226. +/* An implementation of renameat2(..., RENAME_NOREPLACE)
  9227. + * with fallback to a non-atomic version.
  9228. + */
  9229. +int
  9230. +glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
  9231. + int newdirfd, const char *newpath)
  9232. +{
  9233. +#ifndef ENABLE_WRPSEUDO_COMPAT
  9234. + if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_NOREPLACE) < 0)
  9235. + {
  9236. + if (G_IN_SET(errno, EINVAL, ENOSYS))
  9237. + {
  9238. + /* Fall through */
  9239. + }
  9240. + else
  9241. + {
  9242. + return -1;
  9243. + }
  9244. + }
  9245. + else
  9246. + return TRUE;
  9247. +#endif
  9248. +
  9249. + if (linkat (olddirfd, oldpath, newdirfd, newpath, 0) < 0)
  9250. + return -1;
  9251. +
  9252. + if (unlinkat (olddirfd, oldpath, 0) < 0)
  9253. + return -1;
  9254. +
  9255. + return 0;
  9256. +}
  9257. +
  9258. +static gboolean
  9259. +rename_file_noreplace_at (int olddirfd, const char *oldpath,
  9260. + int newdirfd, const char *newpath,
  9261. + gboolean ignore_eexist,
  9262. + GError **error)
  9263. +{
  9264. + if (glnx_renameat2_noreplace (olddirfd, oldpath,
  9265. + newdirfd, newpath) < 0)
  9266. + {
  9267. + if (errno == EEXIST && ignore_eexist)
  9268. + {
  9269. + (void) unlinkat (olddirfd, oldpath, 0);
  9270. + return TRUE;
  9271. + }
  9272. + else
  9273. + return glnx_throw_errno_prefix (error, "renameat");
  9274. + }
  9275. + return TRUE;
  9276. +}
  9277. +
  9278. +/* An implementation of renameat2(..., RENAME_EXCHANGE)
  9279. + * with fallback to a non-atomic version.
  9280. + */
  9281. +int
  9282. +glnx_renameat2_exchange (int olddirfd, const char *oldpath,
  9283. + int newdirfd, const char *newpath)
  9284. +{
  9285. +#ifndef ENABLE_WRPSEUDO_COMPAT
  9286. + if (renameat2 (olddirfd, oldpath, newdirfd, newpath, RENAME_EXCHANGE) == 0)
  9287. + return 0;
  9288. + else
  9289. + {
  9290. + if (G_IN_SET(errno, ENOSYS, EINVAL))
  9291. + {
  9292. + /* Fall through */
  9293. + }
  9294. + else
  9295. + {
  9296. + return -1;
  9297. + }
  9298. + }
  9299. +#endif
  9300. +
  9301. + /* Fallback */
  9302. + { char *old_tmp_name_buf = glnx_strjoina (oldpath, ".XXXXXX");
  9303. + /* This obviously isn't race-free, but doing better gets tricky, since if
  9304. + * we're here the kernel isn't likely to support RENAME_NOREPLACE either.
  9305. + * Anyways, upgrade the kernel. Failing that, avoid use of this function in
  9306. + * shared subdirectories like /tmp.
  9307. + */
  9308. + glnx_gen_temp_name (old_tmp_name_buf);
  9309. + const char *old_tmp_name = old_tmp_name_buf;
  9310. +
  9311. + /* Move old out of the way */
  9312. + if (renameat (olddirfd, oldpath, olddirfd, old_tmp_name) < 0)
  9313. + return -1;
  9314. + /* Now move new into its place */
  9315. + if (renameat (newdirfd, newpath, olddirfd, oldpath) < 0)
  9316. + return -1;
  9317. + /* And finally old(tmp) into new */
  9318. + if (renameat (olddirfd, old_tmp_name, newdirfd, newpath) < 0)
  9319. + return -1;
  9320. + }
  9321. + return 0;
  9322. +}
  9323. +
  9324. +/* Deallocate a tmpfile, closing the fd and deleting the path, if any. This is
  9325. + * normally called by default by the autocleanup attribute, but you can also
  9326. + * invoke this directly.
  9327. + */
  9328. +void
  9329. +glnx_tmpfile_clear (GLnxTmpfile *tmpf)
  9330. +{
  9331. + /* Support being passed NULL so we work nicely in a GPtrArray */
  9332. + if (!tmpf)
  9333. + return;
  9334. + if (!tmpf->initialized)
  9335. + return;
  9336. + glnx_close_fd (&tmpf->fd);
  9337. + /* If ->path is set, we're likely aborting due to an error. Clean it up */
  9338. + if (tmpf->path)
  9339. + {
  9340. + (void) unlinkat (tmpf->src_dfd, tmpf->path, 0);
  9341. + g_free (tmpf->path);
  9342. + }
  9343. + tmpf->initialized = FALSE;
  9344. +}
  9345. +
  9346. +static gboolean
  9347. +open_tmpfile_core (int dfd, const char *subpath,
  9348. + int flags,
  9349. + GLnxTmpfile *out_tmpf,
  9350. + GError **error)
  9351. +{
  9352. + /* Picked this to match mkstemp() */
  9353. + const guint mode = 0600;
  9354. +
  9355. + dfd = glnx_dirfd_canonicalize (dfd);
  9356. +
  9357. + /* Creates a temporary file, that shall be renamed to "target"
  9358. + * later. If possible, this uses O_TMPFILE – in which case
  9359. + * "ret_path" will be returned as NULL. If not possible a the
  9360. + * tempoary path name used is returned in "ret_path". Use
  9361. + * link_tmpfile() below to rename the result after writing the file
  9362. + * in full. */
  9363. +#if defined(O_TMPFILE) && !defined(DISABLE_OTMPFILE) && !defined(ENABLE_WRPSEUDO_COMPAT)
  9364. + {
  9365. + glnx_autofd int fd = openat (dfd, subpath, O_TMPFILE|flags, mode);
  9366. + if (fd == -1 && !(G_IN_SET(errno, ENOSYS, EISDIR, EOPNOTSUPP)))
  9367. + return glnx_throw_errno_prefix (error, "open(O_TMPFILE)");
  9368. + if (fd != -1)
  9369. + {
  9370. + /* Workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=17523
  9371. + * See also https://github.com/ostreedev/ostree/issues/991
  9372. + */
  9373. + if (fchmod (fd, mode) < 0)
  9374. + return glnx_throw_errno_prefix (error, "fchmod");
  9375. + out_tmpf->initialized = TRUE;
  9376. + out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
  9377. + out_tmpf->fd = glnx_steal_fd (&fd);
  9378. + out_tmpf->path = NULL;
  9379. + return TRUE;
  9380. + }
  9381. + }
  9382. + /* Fallthrough */
  9383. +#endif
  9384. +
  9385. + const guint count_max = 100;
  9386. + { g_autofree char *tmp = g_strconcat (subpath, "/tmp.XXXXXX", NULL);
  9387. +
  9388. + for (int count = 0; count < count_max; count++)
  9389. + {
  9390. + glnx_gen_temp_name (tmp);
  9391. +
  9392. + glnx_autofd int fd = openat (dfd, tmp, O_CREAT|O_EXCL|O_NOFOLLOW|O_NOCTTY|flags, mode);
  9393. + if (fd < 0)
  9394. + {
  9395. + if (errno == EEXIST)
  9396. + continue;
  9397. + else
  9398. + return glnx_throw_errno_prefix (error, "Creating temp file");
  9399. + }
  9400. + else
  9401. + {
  9402. + out_tmpf->initialized = TRUE;
  9403. + out_tmpf->src_dfd = dfd; /* Copied; caller must keep open */
  9404. + out_tmpf->fd = glnx_steal_fd (&fd);
  9405. + out_tmpf->path = g_steal_pointer (&tmp);
  9406. + return TRUE;
  9407. + }
  9408. + }
  9409. + }
  9410. + g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
  9411. + "Exhausted %u attempts to create temporary file", count_max);
  9412. + return FALSE;
  9413. +}
  9414. +
  9415. +/* Allocate a temporary file, using Linux O_TMPFILE if available. The file mode
  9416. + * will be 0600.
  9417. + *
  9418. + * The result will be stored in @out_tmpf, which is caller allocated
  9419. + * so you can store it on the stack in common scenarios.
  9420. + *
  9421. + * The directory fd @dfd must live at least as long as the output @out_tmpf.
  9422. + */
  9423. +gboolean
  9424. +glnx_open_tmpfile_linkable_at (int dfd,
  9425. + const char *subpath,
  9426. + int flags,
  9427. + GLnxTmpfile *out_tmpf,
  9428. + GError **error)
  9429. +{
  9430. + /* Don't allow O_EXCL, as that has a special meaning for O_TMPFILE;
  9431. + * it's used for glnx_open_anonymous_tmpfile().
  9432. + */
  9433. + g_return_val_if_fail ((flags & O_EXCL) == 0, FALSE);
  9434. +
  9435. + return open_tmpfile_core (dfd, subpath, flags, out_tmpf, error);
  9436. +}
  9437. +
  9438. +/* A variant of `glnx_open_tmpfile_linkable_at()` which doesn't support linking.
  9439. + * Useful for true temporary storage. The fd will be allocated in /var/tmp to
  9440. + * ensure maximum storage space.
  9441. + */
  9442. +gboolean
  9443. +glnx_open_anonymous_tmpfile (int flags,
  9444. + GLnxTmpfile *out_tmpf,
  9445. + GError **error)
  9446. +{
  9447. + /* Add in O_EXCL */
  9448. + if (!open_tmpfile_core (AT_FDCWD, "/var/tmp", flags | O_EXCL, out_tmpf, error))
  9449. + return FALSE;
  9450. + if (out_tmpf->path)
  9451. + {
  9452. + (void) unlinkat (out_tmpf->src_dfd, out_tmpf->path, 0);
  9453. + g_clear_pointer (&out_tmpf->path, g_free);
  9454. + }
  9455. + out_tmpf->anonymous = TRUE;
  9456. + out_tmpf->src_dfd = -1;
  9457. + return TRUE;
  9458. +}
  9459. +
  9460. +/* Use this after calling glnx_open_tmpfile_linkable_at() to give
  9461. + * the file its final name (link into place).
  9462. + */
  9463. +gboolean
  9464. +glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
  9465. + GLnxLinkTmpfileReplaceMode mode,
  9466. + int target_dfd,
  9467. + const char *target,
  9468. + GError **error)
  9469. +{
  9470. + const gboolean replace = (mode == GLNX_LINK_TMPFILE_REPLACE);
  9471. + const gboolean ignore_eexist = (mode == GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST);
  9472. +
  9473. + g_return_val_if_fail (!tmpf->anonymous, FALSE);
  9474. + g_return_val_if_fail (tmpf->fd >= 0, FALSE);
  9475. + g_return_val_if_fail (tmpf->src_dfd == AT_FDCWD || tmpf->src_dfd >= 0, FALSE);
  9476. +
  9477. + /* Unlike the original systemd code, this function also supports
  9478. + * replacing existing files.
  9479. + */
  9480. +
  9481. + /* We have `tmpfile_path` for old systems without O_TMPFILE. */
  9482. + if (tmpf->path)
  9483. + {
  9484. + if (replace)
  9485. + {
  9486. + /* We have a regular tempfile, we're overwriting - this is a
  9487. + * simple renameat().
  9488. + */
  9489. + if (renameat (tmpf->src_dfd, tmpf->path, target_dfd, target) < 0)
  9490. + return glnx_throw_errno_prefix (error, "renameat");
  9491. + }
  9492. + else
  9493. + {
  9494. + /* We need to use renameat2(..., NOREPLACE) or emulate it */
  9495. + if (!rename_file_noreplace_at (tmpf->src_dfd, tmpf->path, target_dfd, target,
  9496. + ignore_eexist,
  9497. + error))
  9498. + return FALSE;
  9499. + }
  9500. + /* Now, clear the pointer so we don't try to unlink it */
  9501. + g_clear_pointer (&tmpf->path, g_free);
  9502. + }
  9503. + else
  9504. + {
  9505. + /* This case we have O_TMPFILE, so our reference to it is via /proc/self/fd */
  9506. + char proc_fd_path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(tmpf->fd) + 1];
  9507. +
  9508. + sprintf (proc_fd_path, "/proc/self/fd/%i", tmpf->fd);
  9509. +
  9510. + if (replace)
  9511. + {
  9512. + /* In this case, we had our temp file atomically hidden, but now
  9513. + * we need to make it visible in the FS so we can do a rename.
  9514. + * Ideally, linkat() would gain AT_REPLACE or so.
  9515. + */
  9516. + /* TODO - avoid double alloca, we can just alloca a copy of
  9517. + * the pathname plus space for tmp.XXXXX */
  9518. + char *dnbuf = strdupa (target);
  9519. + const char *dn = dirname (dnbuf);
  9520. + char *tmpname_buf = glnx_strjoina (dn, "/tmp.XXXXXX");
  9521. +
  9522. + const guint count_max = 100;
  9523. + guint count;
  9524. + for (count = 0; count < count_max; count++)
  9525. + {
  9526. + glnx_gen_temp_name (tmpname_buf);
  9527. +
  9528. + if (linkat (AT_FDCWD, proc_fd_path, target_dfd, tmpname_buf, AT_SYMLINK_FOLLOW) < 0)
  9529. + {
  9530. + if (errno == EEXIST)
  9531. + continue;
  9532. + else
  9533. + return glnx_throw_errno_prefix (error, "linkat");
  9534. + }
  9535. + else
  9536. + break;
  9537. + }
  9538. + if (count == count_max)
  9539. + {
  9540. + g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
  9541. + "Exhausted %u attempts to create temporary file", count);
  9542. + return FALSE;
  9543. + }
  9544. + if (!glnx_renameat (target_dfd, tmpname_buf, target_dfd, target, error))
  9545. + {
  9546. + /* This is currently the only case where we need to have
  9547. + * a cleanup unlinkat() still with O_TMPFILE.
  9548. + */
  9549. + (void) unlinkat (target_dfd, tmpname_buf, 0);
  9550. + return FALSE;
  9551. + }
  9552. + }
  9553. + else
  9554. + {
  9555. + if (linkat (AT_FDCWD, proc_fd_path, target_dfd, target, AT_SYMLINK_FOLLOW) < 0)
  9556. + {
  9557. + if (errno == EEXIST && mode == GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST)
  9558. + ;
  9559. + else
  9560. + return glnx_throw_errno_prefix (error, "linkat");
  9561. + }
  9562. + }
  9563. +
  9564. + }
  9565. + return TRUE;
  9566. +}
  9567. +
  9568. +/**
  9569. + * glnx_openat_rdonly:
  9570. + * @dfd: File descriptor for origin directory
  9571. + * @path: Pathname, relative to @dfd
  9572. + * @follow: Whether or not to follow symbolic links in the final component
  9573. + * @out_fd: (out): File descriptor
  9574. + * @error: Error
  9575. + *
  9576. + * Use openat() to open a file, with flags `O_RDONLY | O_CLOEXEC | O_NOCTTY`.
  9577. + * Like the other libglnx wrappers, will use `TEMP_FAILURE_RETRY` and
  9578. + * also includes @path in @error in case of failure.
  9579. + */
  9580. +gboolean
  9581. +glnx_openat_rdonly (int dfd,
  9582. + const char *path,
  9583. + gboolean follow,
  9584. + int *out_fd,
  9585. + GError **error)
  9586. +{
  9587. + int flags = O_RDONLY | O_CLOEXEC | O_NOCTTY;
  9588. + if (!follow)
  9589. + flags |= O_NOFOLLOW;
  9590. + int fd = TEMP_FAILURE_RETRY (openat (dfd, path, flags));
  9591. + if (fd == -1)
  9592. + return glnx_throw_errno_prefix (error, "openat(%s)", path);
  9593. + *out_fd = fd;
  9594. + return TRUE;
  9595. +}
  9596. +
  9597. +static guint8*
  9598. +glnx_fd_readall_malloc (int fd,
  9599. + gsize *out_len,
  9600. + gboolean nul_terminate,
  9601. + GCancellable *cancellable,
  9602. + GError **error)
  9603. +{
  9604. + const guint maxreadlen = 4096;
  9605. +
  9606. + struct stat stbuf;
  9607. + if (!glnx_fstat (fd, &stbuf, error))
  9608. + return FALSE;
  9609. +
  9610. + gsize buf_allocated;
  9611. + if (S_ISREG (stbuf.st_mode) && stbuf.st_size > 0)
  9612. + buf_allocated = stbuf.st_size;
  9613. + else
  9614. + buf_allocated = 16;
  9615. +
  9616. + g_autofree guint8* buf = g_malloc (buf_allocated);
  9617. +
  9618. + gsize buf_size = 0;
  9619. + while (TRUE)
  9620. + {
  9621. + gsize readlen = MIN (buf_allocated - buf_size, maxreadlen);
  9622. +
  9623. + if (g_cancellable_set_error_if_cancelled (cancellable, error))
  9624. + return FALSE;
  9625. +
  9626. + gssize bytes_read;
  9627. + do
  9628. + bytes_read = read (fd, buf + buf_size, readlen);
  9629. + while (G_UNLIKELY (bytes_read == -1 && errno == EINTR));
  9630. + if (G_UNLIKELY (bytes_read == -1))
  9631. + return glnx_null_throw_errno (error);
  9632. + if (bytes_read == 0)
  9633. + break;
  9634. +
  9635. + buf_size += bytes_read;
  9636. + if (buf_allocated - buf_size < maxreadlen)
  9637. + buf = g_realloc (buf, buf_allocated *= 2);
  9638. + }
  9639. +
  9640. + if (nul_terminate)
  9641. + {
  9642. + if (buf_allocated - buf_size == 0)
  9643. + buf = g_realloc (buf, buf_allocated + 1);
  9644. + buf[buf_size] = '\0';
  9645. + }
  9646. +
  9647. + *out_len = buf_size;
  9648. + return g_steal_pointer (&buf);
  9649. +}
  9650. +
  9651. +/**
  9652. + * glnx_fd_readall_bytes:
  9653. + * @fd: A file descriptor
  9654. + * @cancellable: Cancellable:
  9655. + * @error: Error
  9656. + *
  9657. + * Read all data from file descriptor @fd into a #GBytes. It's
  9658. + * recommended to only use this for small files.
  9659. + *
  9660. + * Returns: (transfer full): A newly allocated #GBytes
  9661. + */
  9662. +GBytes *
  9663. +glnx_fd_readall_bytes (int fd,
  9664. + GCancellable *cancellable,
  9665. + GError **error)
  9666. +{
  9667. + gsize len;
  9668. + guint8 *buf = glnx_fd_readall_malloc (fd, &len, FALSE, cancellable, error);
  9669. + if (!buf)
  9670. + return NULL;
  9671. + return g_bytes_new_take (buf, len);
  9672. +}
  9673. +
  9674. +/**
  9675. + * glnx_fd_readall_utf8:
  9676. + * @fd: A file descriptor
  9677. + * @out_len: (out): Returned length
  9678. + * @cancellable: Cancellable:
  9679. + * @error: Error
  9680. + *
  9681. + * Read all data from file descriptor @fd, validating
  9682. + * the result as UTF-8.
  9683. + *
  9684. + * Returns: (transfer full): A string validated as UTF-8, or %NULL on error.
  9685. + */
  9686. +char *
  9687. +glnx_fd_readall_utf8 (int fd,
  9688. + gsize *out_len,
  9689. + GCancellable *cancellable,
  9690. + GError **error)
  9691. +{
  9692. + gsize len;
  9693. + g_autofree guint8 *buf = glnx_fd_readall_malloc (fd, &len, TRUE, cancellable, error);
  9694. + if (!buf)
  9695. + return FALSE;
  9696. +
  9697. + if (!g_utf8_validate ((char*)buf, len, NULL))
  9698. + {
  9699. + g_set_error (error,
  9700. + G_IO_ERROR,
  9701. + G_IO_ERROR_INVALID_DATA,
  9702. + "Invalid UTF-8");
  9703. + return FALSE;
  9704. + }
  9705. +
  9706. + if (out_len)
  9707. + *out_len = len;
  9708. + return (char*)g_steal_pointer (&buf);
  9709. +}
  9710. +
  9711. +/**
  9712. + * glnx_file_get_contents_utf8_at:
  9713. + * @dfd: Directory file descriptor
  9714. + * @subpath: Path relative to @dfd
  9715. + * @out_len: (out) (allow-none): Optional length
  9716. + * @cancellable: Cancellable
  9717. + * @error: Error
  9718. + *
  9719. + * Read the entire contents of the file referred
  9720. + * to by @dfd and @subpath, validate the result as UTF-8.
  9721. + * The length is optionally stored in @out_len.
  9722. + *
  9723. + * Returns: (transfer full): UTF-8 validated text, or %NULL on error
  9724. + */
  9725. +char *
  9726. +glnx_file_get_contents_utf8_at (int dfd,
  9727. + const char *subpath,
  9728. + gsize *out_len,
  9729. + GCancellable *cancellable,
  9730. + GError **error)
  9731. +{
  9732. + dfd = glnx_dirfd_canonicalize (dfd);
  9733. +
  9734. + glnx_autofd int fd = -1;
  9735. + if (!glnx_openat_rdonly (dfd, subpath, TRUE, &fd, error))
  9736. + return NULL;
  9737. +
  9738. + gsize len;
  9739. + g_autofree char *buf = glnx_fd_readall_utf8 (fd, &len, cancellable, error);
  9740. + if (G_UNLIKELY(!buf))
  9741. + return FALSE;
  9742. +
  9743. + if (out_len)
  9744. + *out_len = len;
  9745. + return g_steal_pointer (&buf);
  9746. +}
  9747. +
  9748. +/**
  9749. + * glnx_readlinkat_malloc:
  9750. + * @dfd: Directory file descriptor
  9751. + * @subpath: Subpath
  9752. + * @cancellable: Cancellable
  9753. + * @error: Error
  9754. + *
  9755. + * Read the value of a symlink into a dynamically
  9756. + * allocated buffer.
  9757. + */
  9758. +char *
  9759. +glnx_readlinkat_malloc (int dfd,
  9760. + const char *subpath,
  9761. + GCancellable *cancellable,
  9762. + GError **error)
  9763. +{
  9764. + dfd = glnx_dirfd_canonicalize (dfd);
  9765. +
  9766. + size_t l = 100;
  9767. + for (;;)
  9768. + {
  9769. + g_autofree char *c = g_malloc (l);
  9770. + ssize_t n = TEMP_FAILURE_RETRY (readlinkat (dfd, subpath, c, l-1));
  9771. + if (n < 0)
  9772. + return glnx_null_throw_errno_prefix (error, "readlinkat");
  9773. +
  9774. + if ((size_t) n < l-1)
  9775. + {
  9776. + c[n] = 0;
  9777. + return g_steal_pointer (&c);
  9778. + }
  9779. +
  9780. + l *= 2;
  9781. + }
  9782. +
  9783. + g_assert_not_reached ();
  9784. +}
  9785. +
  9786. +static gboolean
  9787. +copy_symlink_at (int src_dfd,
  9788. + const char *src_subpath,
  9789. + const struct stat *src_stbuf,
  9790. + int dest_dfd,
  9791. + const char *dest_subpath,
  9792. + GLnxFileCopyFlags copyflags,
  9793. + GCancellable *cancellable,
  9794. + GError **error)
  9795. +{
  9796. + g_autofree char *buf = glnx_readlinkat_malloc (src_dfd, src_subpath, cancellable, error);
  9797. + if (!buf)
  9798. + return FALSE;
  9799. +
  9800. + if (TEMP_FAILURE_RETRY (symlinkat (buf, dest_dfd, dest_subpath)) != 0)
  9801. + return glnx_throw_errno_prefix (error, "symlinkat");
  9802. +
  9803. + if (!(copyflags & GLNX_FILE_COPY_NOXATTRS))
  9804. + {
  9805. + g_autoptr(GVariant) xattrs = NULL;
  9806. +
  9807. + if (!glnx_dfd_name_get_all_xattrs (src_dfd, src_subpath, &xattrs,
  9808. + cancellable, error))
  9809. + return FALSE;
  9810. +
  9811. + if (!glnx_dfd_name_set_all_xattrs (dest_dfd, dest_subpath, xattrs,
  9812. + cancellable, error))
  9813. + return FALSE;
  9814. + }
  9815. +
  9816. + if (TEMP_FAILURE_RETRY (fchownat (dest_dfd, dest_subpath,
  9817. + src_stbuf->st_uid, src_stbuf->st_gid,
  9818. + AT_SYMLINK_NOFOLLOW)) != 0)
  9819. + return glnx_throw_errno_prefix (error, "fchownat");
  9820. +
  9821. + return TRUE;
  9822. +}
  9823. +
  9824. +#define COPY_BUFFER_SIZE (16*1024)
  9825. +
  9826. +/* Most of the code below is from systemd, but has been reindented to GNU style,
  9827. + * and changed to use POSIX error conventions (return -1, set errno) to more
  9828. + * conveniently fit in with the rest of libglnx.
  9829. + */
  9830. +
  9831. +/* Like write(), but loop until @nbytes are written, or an error
  9832. + * occurs.
  9833. + *
  9834. + * On error, -1 is returned an @errno is set. NOTE: This is an
  9835. + * API change from previous versions of this function.
  9836. + */
  9837. +int
  9838. +glnx_loop_write(int fd, const void *buf, size_t nbytes)
  9839. +{
  9840. + g_return_val_if_fail (fd >= 0, -1);
  9841. + g_return_val_if_fail (buf, -1);
  9842. +
  9843. + errno = 0;
  9844. +
  9845. + const uint8_t *p = buf;
  9846. + while (nbytes > 0)
  9847. + {
  9848. + ssize_t k = write(fd, p, nbytes);
  9849. + if (k < 0)
  9850. + {
  9851. + if (errno == EINTR)
  9852. + continue;
  9853. +
  9854. + return -1;
  9855. + }
  9856. +
  9857. + if (k == 0) /* Can't really happen */
  9858. + {
  9859. + errno = EIO;
  9860. + return -1;
  9861. + }
  9862. +
  9863. + p += k;
  9864. + nbytes -= k;
  9865. + }
  9866. +
  9867. + return 0;
  9868. +}
  9869. +
  9870. +/* Read from @fdf until EOF, writing to @fdt. If max_bytes is -1, a full-file
  9871. + * clone will be attempted. Otherwise Linux copy_file_range(), sendfile()
  9872. + * syscall will be attempted. If none of those work, this function will do a
  9873. + * plain read()/write() loop.
  9874. + *
  9875. + * The file descriptor @fdf must refer to a regular file.
  9876. + *
  9877. + * If provided, @max_bytes specifies the maximum number of bytes to read from @fdf.
  9878. + * On error, this function returns `-1` and @errno will be set.
  9879. + */
  9880. +int
  9881. +glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes)
  9882. +{
  9883. + /* Last updates from systemd as of commit 6bda23dd6aaba50cf8e3e6024248cf736cc443ca */
  9884. + static int have_cfr = -1; /* -1 means unknown */
  9885. + bool try_cfr = have_cfr != 0;
  9886. + static int have_sendfile = -1; /* -1 means unknown */
  9887. + bool try_sendfile = have_sendfile != 0;
  9888. +
  9889. + g_return_val_if_fail (fdf >= 0, -1);
  9890. + g_return_val_if_fail (fdt >= 0, -1);
  9891. + g_return_val_if_fail (max_bytes >= -1, -1);
  9892. +
  9893. + /* If we've requested to copy the whole range, try a full-file clone first.
  9894. + */
  9895. + if (max_bytes == (off_t) -1)
  9896. + {
  9897. + if (ioctl (fdt, FICLONE, fdf) == 0)
  9898. + return 0;
  9899. + /* Fall through */
  9900. + struct stat stbuf;
  9901. +
  9902. + /* Gather the size so we can provide the whole thing at once to
  9903. + * copy_file_range() or sendfile().
  9904. + */
  9905. + if (fstat (fdf, &stbuf) < 0)
  9906. + return -1;
  9907. + max_bytes = stbuf.st_size;
  9908. + }
  9909. +
  9910. + while (TRUE)
  9911. + {
  9912. + ssize_t n;
  9913. +
  9914. + /* First, try copy_file_range(). Note this is an inlined version of
  9915. + * try_copy_file_range() from systemd upstream, which works better since
  9916. + * we use POSIX errno style.
  9917. + */
  9918. + if (try_cfr)
  9919. + {
  9920. + n = copy_file_range (fdf, NULL, fdt, NULL, max_bytes, 0u);
  9921. + if (n < 0)
  9922. + {
  9923. + if (errno == ENOSYS)
  9924. + {
  9925. + /* No cfr in kernel, mark as permanently unavailable
  9926. + * and fall through to sendfile().
  9927. + */
  9928. + have_cfr = 0;
  9929. + try_cfr = false;
  9930. + }
  9931. + else if (errno == EXDEV)
  9932. + /* We won't try cfr again for this run, but let's be
  9933. + * conservative and not mark it as available/unavailable until
  9934. + * we know for sure.
  9935. + */
  9936. + try_cfr = false;
  9937. + else
  9938. + return -1;
  9939. + }
  9940. + else
  9941. + {
  9942. + /* cfr worked, mark it as available */
  9943. + if (have_cfr == -1)
  9944. + have_cfr = 1;
  9945. +
  9946. + if (n == 0) /* EOF */
  9947. + break;
  9948. + else
  9949. + /* Success! */
  9950. + goto next;
  9951. + }
  9952. + }
  9953. +
  9954. + /* Next try sendfile(); this version is also changed from systemd upstream
  9955. + * to match the same logic we have for copy_file_range().
  9956. + */
  9957. + if (try_sendfile)
  9958. + {
  9959. + n = sendfile (fdt, fdf, NULL, max_bytes);
  9960. + if (n < 0)
  9961. + {
  9962. + if (G_IN_SET (errno, EINVAL, ENOSYS))
  9963. + {
  9964. + /* No sendfile(), or it doesn't work on regular files.
  9965. + * Mark it as permanently unavailable, and fall through
  9966. + * to plain read()/write().
  9967. + */
  9968. + have_sendfile = 0;
  9969. + try_sendfile = false;
  9970. + }
  9971. + else
  9972. + return -1;
  9973. + }
  9974. + else
  9975. + {
  9976. + /* sendfile() worked, mark it as available */
  9977. + if (have_sendfile == -1)
  9978. + have_sendfile = 1;
  9979. +
  9980. + if (n == 0) /* EOF */
  9981. + break;
  9982. + else if (n > 0)
  9983. + /* Succcess! */
  9984. + goto next;
  9985. + }
  9986. + }
  9987. +
  9988. + /* As a fallback just copy bits by hand */
  9989. + { size_t m = COPY_BUFFER_SIZE;
  9990. + if (max_bytes != (off_t) -1)
  9991. + {
  9992. + if ((off_t) m > max_bytes)
  9993. + m = (size_t) max_bytes;
  9994. + }
  9995. + char buf[m];
  9996. +
  9997. + n = TEMP_FAILURE_RETRY (read (fdf, buf, m));
  9998. + if (n < 0)
  9999. + return -1;
  10000. + if (n == 0) /* EOF */
  10001. + break;
  10002. +
  10003. + if (glnx_loop_write (fdt, buf, (size_t) n) < 0)
  10004. + return -1;
  10005. + }
  10006. +
  10007. + next:
  10008. + if (max_bytes != (off_t) -1)
  10009. + {
  10010. + g_assert_cmpint (max_bytes, >=, n);
  10011. + max_bytes -= n;
  10012. + if (max_bytes == 0)
  10013. + break;
  10014. + }
  10015. + }
  10016. +
  10017. + return 0;
  10018. +}
  10019. +
  10020. +/**
  10021. + * glnx_file_copy_at:
  10022. + * @src_dfd: Source directory fd
  10023. + * @src_subpath: Subpath relative to @src_dfd
  10024. + * @src_stbuf: (allow-none): Optional stat buffer for source; if a stat() has already been done
  10025. + * @dest_dfd: Target directory fd
  10026. + * @dest_subpath: Destination name
  10027. + * @copyflags: Flags
  10028. + * @cancellable: cancellable
  10029. + * @error: Error
  10030. + *
  10031. + * Perform a full copy of the regular file or symbolic link from @src_subpath to
  10032. + * @dest_subpath; if @src_subpath is anything other than a regular file or
  10033. + * symbolic link, an error will be returned.
  10034. + *
  10035. + * If the source is a regular file and the destination exists as a symbolic
  10036. + * link, the symbolic link will not be followed; rather the link itself will be
  10037. + * replaced. Related to this: for regular files, when `GLNX_FILE_COPY_OVERWRITE`
  10038. + * is specified, this function always uses `O_TMPFILE` (if available) and does a
  10039. + * rename-into-place rather than `open(O_TRUNC)`.
  10040. + */
  10041. +gboolean
  10042. +glnx_file_copy_at (int src_dfd,
  10043. + const char *src_subpath,
  10044. + struct stat *src_stbuf,
  10045. + int dest_dfd,
  10046. + const char *dest_subpath,
  10047. + GLnxFileCopyFlags copyflags,
  10048. + GCancellable *cancellable,
  10049. + GError **error)
  10050. +{
  10051. + /* Canonicalize dfds */
  10052. + src_dfd = glnx_dirfd_canonicalize (src_dfd);
  10053. + dest_dfd = glnx_dirfd_canonicalize (dest_dfd);
  10054. +
  10055. + if (g_cancellable_set_error_if_cancelled (cancellable, error))
  10056. + return FALSE;
  10057. +
  10058. + /* Automatically do stat() if no stat buffer was supplied */
  10059. + struct stat local_stbuf;
  10060. + if (!src_stbuf)
  10061. + {
  10062. + if (!glnx_fstatat (src_dfd, src_subpath, &local_stbuf, AT_SYMLINK_NOFOLLOW, error))
  10063. + return FALSE;
  10064. + src_stbuf = &local_stbuf;
  10065. + }
  10066. +
  10067. + /* For symlinks, defer entirely to copy_symlink_at() */
  10068. + if (S_ISLNK (src_stbuf->st_mode))
  10069. + {
  10070. + return copy_symlink_at (src_dfd, src_subpath, src_stbuf,
  10071. + dest_dfd, dest_subpath,
  10072. + copyflags,
  10073. + cancellable, error);
  10074. + }
  10075. + else if (!S_ISREG (src_stbuf->st_mode))
  10076. + {
  10077. + g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
  10078. + "Cannot copy non-regular/non-symlink file: %s", src_subpath);
  10079. + return FALSE;
  10080. + }
  10081. +
  10082. + /* Regular file path below here */
  10083. +
  10084. + glnx_autofd int src_fd = -1;
  10085. + if (!glnx_openat_rdonly (src_dfd, src_subpath, FALSE, &src_fd, error))
  10086. + return FALSE;
  10087. +
  10088. + /* Open a tmpfile for dest. Particularly for AT_FDCWD calls, we really want to
  10089. + * open in the target directory, otherwise we may not be able to link.
  10090. + */
  10091. + g_auto(GLnxTmpfile) tmp_dest = { 0, };
  10092. + { char *dnbuf = strdupa (dest_subpath);
  10093. + const char *dn = dirname (dnbuf);
  10094. + if (!glnx_open_tmpfile_linkable_at (dest_dfd, dn, O_WRONLY | O_CLOEXEC,
  10095. + &tmp_dest, error))
  10096. + return FALSE;
  10097. + }
  10098. +
  10099. + if (glnx_regfile_copy_bytes (src_fd, tmp_dest.fd, (off_t) -1) < 0)
  10100. + return glnx_throw_errno_prefix (error, "regfile copy");
  10101. +
  10102. + if (fchown (tmp_dest.fd, src_stbuf->st_uid, src_stbuf->st_gid) != 0)
  10103. + return glnx_throw_errno_prefix (error, "fchown");
  10104. +
  10105. + if (!(copyflags & GLNX_FILE_COPY_NOXATTRS))
  10106. + {
  10107. + g_autoptr(GVariant) xattrs = NULL;
  10108. +
  10109. + if (!glnx_fd_get_all_xattrs (src_fd, &xattrs,
  10110. + cancellable, error))
  10111. + return FALSE;
  10112. +
  10113. + if (!glnx_fd_set_all_xattrs (tmp_dest.fd, xattrs,
  10114. + cancellable, error))
  10115. + return FALSE;
  10116. + }
  10117. +
  10118. + /* Always chmod after setting xattrs, in case the file has mode 0400 or less,
  10119. + * like /etc/shadow. Linux currently allows write() on non-writable open files
  10120. + * but not fsetxattr().
  10121. + */
  10122. + if (fchmod (tmp_dest.fd, src_stbuf->st_mode & 07777) != 0)
  10123. + return glnx_throw_errno_prefix (error, "fchmod");
  10124. +
  10125. + struct timespec ts[2];
  10126. + ts[0] = src_stbuf->st_atim;
  10127. + ts[1] = src_stbuf->st_mtim;
  10128. + (void) futimens (tmp_dest.fd, ts);
  10129. +
  10130. + if (copyflags & GLNX_FILE_COPY_DATASYNC)
  10131. + {
  10132. + if (fdatasync (tmp_dest.fd) < 0)
  10133. + return glnx_throw_errno_prefix (error, "fdatasync");
  10134. + }
  10135. +
  10136. + const GLnxLinkTmpfileReplaceMode replacemode =
  10137. + (copyflags & GLNX_FILE_COPY_OVERWRITE) ?
  10138. + GLNX_LINK_TMPFILE_REPLACE :
  10139. + GLNX_LINK_TMPFILE_NOREPLACE;
  10140. +
  10141. + if (!glnx_link_tmpfile_at (&tmp_dest, replacemode, dest_dfd, dest_subpath, error))
  10142. + return FALSE;
  10143. +
  10144. + return TRUE;
  10145. +}
  10146. +
  10147. +/**
  10148. + * glnx_file_replace_contents_at:
  10149. + * @dfd: Directory fd
  10150. + * @subpath: Subpath
  10151. + * @buf: (array len=len) (element-type guint8): File contents
  10152. + * @len: Length (if `-1`, assume @buf is `NUL` terminated)
  10153. + * @flags: Flags
  10154. + * @cancellable: Cancellable
  10155. + * @error: Error
  10156. + *
  10157. + * Create a new file, atomically replacing the contents of @subpath
  10158. + * (relative to @dfd) with @buf. By default, if the file already
  10159. + * existed, fdatasync() will be used before rename() to ensure stable
  10160. + * contents. This and other behavior can be controlled via @flags.
  10161. + *
  10162. + * Note that no metadata from the existing file is preserved, such as
  10163. + * uid/gid or extended attributes. The default mode will be `0666`,
  10164. + * modified by umask.
  10165. + */
  10166. +gboolean
  10167. +glnx_file_replace_contents_at (int dfd,
  10168. + const char *subpath,
  10169. + const guint8 *buf,
  10170. + gsize len,
  10171. + GLnxFileReplaceFlags flags,
  10172. + GCancellable *cancellable,
  10173. + GError **error)
  10174. +{
  10175. + return glnx_file_replace_contents_with_perms_at (dfd, subpath, buf, len,
  10176. + (mode_t) -1, (uid_t) -1, (gid_t) -1,
  10177. + flags, cancellable, error);
  10178. +}
  10179. +
  10180. +/**
  10181. + * glnx_file_replace_contents_with_perms_at:
  10182. + * @dfd: Directory fd
  10183. + * @subpath: Subpath
  10184. + * @buf: (array len=len) (element-type guint8): File contents
  10185. + * @len: Length (if `-1`, assume @buf is `NUL` terminated)
  10186. + * @mode: File mode; if `-1`, use `0666 - umask`
  10187. + * @flags: Flags
  10188. + * @cancellable: Cancellable
  10189. + * @error: Error
  10190. + *
  10191. + * Like glnx_file_replace_contents_at(), but also supports
  10192. + * setting mode, and uid/gid.
  10193. + */
  10194. +gboolean
  10195. +glnx_file_replace_contents_with_perms_at (int dfd,
  10196. + const char *subpath,
  10197. + const guint8 *buf,
  10198. + gsize len,
  10199. + mode_t mode,
  10200. + uid_t uid,
  10201. + gid_t gid,
  10202. + GLnxFileReplaceFlags flags,
  10203. + GCancellable *cancellable,
  10204. + GError **error)
  10205. +{
  10206. + char *dnbuf = strdupa (subpath);
  10207. + const char *dn = dirname (dnbuf);
  10208. +
  10209. + dfd = glnx_dirfd_canonicalize (dfd);
  10210. +
  10211. + /* With O_TMPFILE we can't use umask, and we can't sanely query the
  10212. + * umask...let's assume something relatively standard.
  10213. + */
  10214. + if (mode == (mode_t) -1)
  10215. + mode = 0644;
  10216. +
  10217. + g_auto(GLnxTmpfile) tmpf = { 0, };
  10218. + if (!glnx_open_tmpfile_linkable_at (dfd, dn, O_WRONLY | O_CLOEXEC,
  10219. + &tmpf, error))
  10220. + return FALSE;
  10221. +
  10222. + if (len == -1)
  10223. + len = strlen ((char*)buf);
  10224. +
  10225. + if (!glnx_try_fallocate (tmpf.fd, 0, len, error))
  10226. + return FALSE;
  10227. +
  10228. + if (glnx_loop_write (tmpf.fd, buf, len) < 0)
  10229. + return glnx_throw_errno_prefix (error, "write");
  10230. +
  10231. + if (!(flags & GLNX_FILE_REPLACE_NODATASYNC))
  10232. + {
  10233. + struct stat stbuf;
  10234. + gboolean do_sync;
  10235. +
  10236. + if (!glnx_fstatat_allow_noent (dfd, subpath, &stbuf, AT_SYMLINK_NOFOLLOW, error))
  10237. + return FALSE;
  10238. + if (errno == ENOENT)
  10239. + do_sync = (flags & GLNX_FILE_REPLACE_DATASYNC_NEW) > 0;
  10240. + else
  10241. + do_sync = TRUE;
  10242. +
  10243. + if (do_sync)
  10244. + {
  10245. + if (fdatasync (tmpf.fd) != 0)
  10246. + return glnx_throw_errno_prefix (error, "fdatasync");
  10247. + }
  10248. + }
  10249. +
  10250. + if (uid != (uid_t) -1)
  10251. + {
  10252. + if (fchown (tmpf.fd, uid, gid) != 0)
  10253. + return glnx_throw_errno_prefix (error, "fchown");
  10254. + }
  10255. +
  10256. + if (fchmod (tmpf.fd, mode) != 0)
  10257. + return glnx_throw_errno_prefix (error, "fchmod");
  10258. +
  10259. + if (!glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_REPLACE,
  10260. + dfd, subpath, error))
  10261. + return FALSE;
  10262. +
  10263. + return TRUE;
  10264. +}
  10265. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-fdio.h flatpak-1.0.0/libglnx/glnx-fdio.h
  10266. --- flatpak-1.0.0.orig/libglnx/glnx-fdio.h 1970-01-01 02:00:00.000000000 +0200
  10267. +++ flatpak-1.0.0/libglnx/glnx-fdio.h 2018-05-26 00:50:25.434037228 +0300
  10268. @@ -0,0 +1,369 @@
  10269. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  10270. + *
  10271. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  10272. + *
  10273. + * This library is free software; you can redistribute it and/or
  10274. + * modify it under the terms of the GNU Lesser General Public
  10275. + * License as published by the Free Software Foundation; either
  10276. + * version 2 of the License, or (at your option) any later version.
  10277. + *
  10278. + * This library is distributed in the hope that it will be useful,
  10279. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10280. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10281. + * Lesser General Public License for more details.
  10282. + *
  10283. + * You should have received a copy of the GNU Lesser General Public
  10284. + * License along with this library; if not, write to the
  10285. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  10286. + * Boston, MA 02111-1307, USA.
  10287. + */
  10288. +
  10289. +#pragma once
  10290. +
  10291. +#include <glnx-backport-autocleanups.h>
  10292. +#include <gio/gfiledescriptorbased.h>
  10293. +#include <limits.h>
  10294. +#include <dirent.h>
  10295. +#include <sys/stat.h>
  10296. +#include <fcntl.h>
  10297. +#include <string.h>
  10298. +#include <stdio.h>
  10299. +#include <sys/xattr.h>
  10300. +// For dirname(), and previously basename()
  10301. +#include <libgen.h>
  10302. +
  10303. +#include <glnx-macros.h>
  10304. +#include <glnx-errors.h>
  10305. +
  10306. +G_BEGIN_DECLS
  10307. +
  10308. +/* Irritatingly, g_basename() which is what we want
  10309. + * is deprecated.
  10310. + */
  10311. +static inline
  10312. +const char *glnx_basename (const char *path)
  10313. +{
  10314. + gchar *base = strrchr (path, G_DIR_SEPARATOR);
  10315. +
  10316. + if (base)
  10317. + return base + 1;
  10318. +
  10319. + return path;
  10320. +}
  10321. +
  10322. +/* Utilities for standard FILE* */
  10323. +static inline void
  10324. +glnx_stdio_file_cleanup (void *filep)
  10325. +{
  10326. + FILE *f = filep;
  10327. + if (f)
  10328. + fclose (f);
  10329. +}
  10330. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(FILE, glnx_stdio_file_cleanup)
  10331. +
  10332. +/**
  10333. + * glnx_stdio_file_flush:
  10334. + * Call fflush() and check ferror().
  10335. + */
  10336. +gboolean
  10337. +glnx_stdio_file_flush (FILE *f, GError **error);
  10338. +
  10339. +typedef struct {
  10340. + gboolean initialized;
  10341. + gboolean anonymous;
  10342. + int src_dfd;
  10343. + int fd;
  10344. + char *path;
  10345. +} GLnxTmpfile;
  10346. +void glnx_tmpfile_clear (GLnxTmpfile *tmpf);
  10347. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxTmpfile, glnx_tmpfile_clear)
  10348. +
  10349. +gboolean
  10350. +glnx_open_anonymous_tmpfile (int flags,
  10351. + GLnxTmpfile *out_tmpf,
  10352. + GError **error);
  10353. +
  10354. +gboolean
  10355. +glnx_open_tmpfile_linkable_at (int dfd,
  10356. + const char *subpath,
  10357. + int flags,
  10358. + GLnxTmpfile *out_tmpf,
  10359. + GError **error);
  10360. +
  10361. +typedef enum {
  10362. + GLNX_LINK_TMPFILE_REPLACE,
  10363. + GLNX_LINK_TMPFILE_NOREPLACE,
  10364. + GLNX_LINK_TMPFILE_NOREPLACE_IGNORE_EXIST
  10365. +} GLnxLinkTmpfileReplaceMode;
  10366. +
  10367. +gboolean
  10368. +glnx_link_tmpfile_at (GLnxTmpfile *tmpf,
  10369. + GLnxLinkTmpfileReplaceMode flags,
  10370. + int target_dfd,
  10371. + const char *target,
  10372. + GError **error);
  10373. +
  10374. +gboolean
  10375. +glnx_openat_rdonly (int dfd,
  10376. + const char *path,
  10377. + gboolean follow,
  10378. + int *out_fd,
  10379. + GError **error);
  10380. +
  10381. +GBytes *
  10382. +glnx_fd_readall_bytes (int fd,
  10383. + GCancellable *cancellable,
  10384. + GError **error);
  10385. +
  10386. +char *
  10387. +glnx_fd_readall_utf8 (int fd,
  10388. + gsize *out_len,
  10389. + GCancellable *cancellable,
  10390. + GError **error);
  10391. +
  10392. +char *
  10393. +glnx_file_get_contents_utf8_at (int dfd,
  10394. + const char *subpath,
  10395. + gsize *out_len,
  10396. + GCancellable *cancellable,
  10397. + GError **error);
  10398. +
  10399. +/**
  10400. + * GLnxFileReplaceFlags:
  10401. + * @GLNX_FILE_REPLACE_DATASYNC_NEW: Call fdatasync() even if the file did not exist
  10402. + * @GLNX_FILE_REPLACE_NODATASYNC: Never call fdatasync()
  10403. + *
  10404. + * Flags controlling file replacement.
  10405. + */
  10406. +typedef enum {
  10407. + GLNX_FILE_REPLACE_DATASYNC_NEW = (1 << 0),
  10408. + GLNX_FILE_REPLACE_NODATASYNC = (1 << 1),
  10409. +} GLnxFileReplaceFlags;
  10410. +
  10411. +gboolean
  10412. +glnx_file_replace_contents_at (int dfd,
  10413. + const char *subpath,
  10414. + const guint8 *buf,
  10415. + gsize len,
  10416. + GLnxFileReplaceFlags flags,
  10417. + GCancellable *cancellable,
  10418. + GError **error);
  10419. +
  10420. +gboolean
  10421. +glnx_file_replace_contents_with_perms_at (int dfd,
  10422. + const char *subpath,
  10423. + const guint8 *buf,
  10424. + gsize len,
  10425. + mode_t mode,
  10426. + uid_t uid,
  10427. + gid_t gid,
  10428. + GLnxFileReplaceFlags flags,
  10429. + GCancellable *cancellable,
  10430. + GError **error);
  10431. +
  10432. +char *
  10433. +glnx_readlinkat_malloc (int dfd,
  10434. + const char *subpath,
  10435. + GCancellable *cancellable,
  10436. + GError **error);
  10437. +
  10438. +int
  10439. +glnx_loop_write (int fd, const void *buf, size_t nbytes);
  10440. +
  10441. +int
  10442. +glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes);
  10443. +
  10444. +typedef enum {
  10445. + GLNX_FILE_COPY_OVERWRITE = (1 << 0),
  10446. + GLNX_FILE_COPY_NOXATTRS = (1 << 1),
  10447. + GLNX_FILE_COPY_DATASYNC = (1 << 2)
  10448. +} GLnxFileCopyFlags;
  10449. +
  10450. +gboolean
  10451. +glnx_file_copy_at (int src_dfd,
  10452. + const char *src_subpath,
  10453. + struct stat *src_stbuf,
  10454. + int dest_dfd,
  10455. + const char *dest_subpath,
  10456. + GLnxFileCopyFlags copyflags,
  10457. + GCancellable *cancellable,
  10458. + GError **error);
  10459. +
  10460. +int glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
  10461. + int newdirfd, const char *newpath);
  10462. +int glnx_renameat2_exchange (int olddirfd, const char *oldpath,
  10463. + int newdirfd, const char *newpath);
  10464. +
  10465. +/**
  10466. + * glnx_try_fallocate:
  10467. + * @fd: File descriptor
  10468. + * @size: Size
  10469. + * @error: Error
  10470. + *
  10471. + * Wrapper for Linux fallocate(). Explicitly ignores a @size of zero.
  10472. + * Also, will silently do nothing if the underlying filesystem doesn't
  10473. + * support it. Use this instead of posix_fallocate(), since the glibc fallback
  10474. + * is bad: https://sourceware.org/bugzilla/show_bug.cgi?id=18515
  10475. + */
  10476. +static inline gboolean
  10477. +glnx_try_fallocate (int fd,
  10478. + off_t offset,
  10479. + off_t size,
  10480. + GError **error)
  10481. +{
  10482. + /* This is just nicer than throwing an error */
  10483. + if (size == 0)
  10484. + return TRUE;
  10485. +
  10486. + if (fallocate (fd, 0, offset, size) < 0)
  10487. + {
  10488. + if (G_IN_SET(errno, ENOSYS, EOPNOTSUPP))
  10489. + ; /* Ignore */
  10490. + else
  10491. + return glnx_throw_errno_prefix (error, "fallocate");
  10492. + }
  10493. +
  10494. + return TRUE;
  10495. +}
  10496. +
  10497. +/**
  10498. + * glnx_fstat:
  10499. + * @fd: FD to stat
  10500. + * @buf: (out caller-allocates): Return location for stat details
  10501. + * @error: Return location for a #GError, or %NULL
  10502. + *
  10503. + * Wrapper around fstat() which adds #GError support and ensures that it retries
  10504. + * on %EINTR.
  10505. + *
  10506. + * Returns: %TRUE on success, %FALSE otherwise
  10507. + * Since: UNRELEASED
  10508. + */
  10509. +static inline gboolean
  10510. +glnx_fstat (int fd,
  10511. + struct stat *buf,
  10512. + GError **error)
  10513. +{
  10514. + if (TEMP_FAILURE_RETRY (fstat (fd, buf)) != 0)
  10515. + return glnx_throw_errno_prefix (error, "fstat");
  10516. + return TRUE;
  10517. +}
  10518. +
  10519. +/**
  10520. + * glnx_fchmod:
  10521. + * @fd: FD
  10522. + * @mode: Mode
  10523. + * @error: Return location for a #GError, or %NULL
  10524. + *
  10525. + * Wrapper around fchmod() which adds #GError support and ensures that it
  10526. + * retries on %EINTR.
  10527. + *
  10528. + * Returns: %TRUE on success, %FALSE otherwise
  10529. + * Since: UNRELEASED
  10530. + */
  10531. +static inline gboolean
  10532. +glnx_fchmod (int fd,
  10533. + mode_t mode,
  10534. + GError **error)
  10535. +{
  10536. + if (TEMP_FAILURE_RETRY (fchmod (fd, mode)) != 0)
  10537. + return glnx_throw_errno_prefix (error, "fchmod");
  10538. + return TRUE;
  10539. +}
  10540. +
  10541. +/**
  10542. + * glnx_fstatat:
  10543. + * @dfd: Directory FD to stat beneath
  10544. + * @path: Path to stat beneath @dfd
  10545. + * @buf: (out caller-allocates): Return location for stat details
  10546. + * @flags: Flags to pass to fstatat()
  10547. + * @error: Return location for a #GError, or %NULL
  10548. + *
  10549. + * Wrapper around fstatat() which adds #GError support and ensures that it
  10550. + * retries on %EINTR.
  10551. + *
  10552. + * Returns: %TRUE on success, %FALSE otherwise
  10553. + * Since: UNRELEASED
  10554. + */
  10555. +static inline gboolean
  10556. +glnx_fstatat (int dfd,
  10557. + const gchar *path,
  10558. + struct stat *buf,
  10559. + int flags,
  10560. + GError **error)
  10561. +{
  10562. + if (TEMP_FAILURE_RETRY (fstatat (dfd, path, buf, flags)) != 0)
  10563. + return glnx_throw_errno_prefix (error, "fstatat(%s)", path);
  10564. + return TRUE;
  10565. +}
  10566. +
  10567. +/**
  10568. + * glnx_fstatat_allow_noent:
  10569. + * @dfd: Directory FD to stat beneath
  10570. + * @path: Path to stat beneath @dfd
  10571. + * @buf: (out caller-allocates) (allow-none): Return location for stat details
  10572. + * @flags: Flags to pass to fstatat()
  10573. + * @error: Return location for a #GError, or %NULL
  10574. + *
  10575. + * Like glnx_fstatat(), but handles `ENOENT` in a non-error way. Instead,
  10576. + * on success `errno` will be zero, otherwise it will be preserved. Hence
  10577. + * you can test `if (errno == 0)` to conditionalize on the file existing,
  10578. + * or `if (errno == ENOENT)` for non-existence.
  10579. + *
  10580. + * Returns: %TRUE on success, %FALSE otherwise (errno is preserved)
  10581. + * Since: UNRELEASED
  10582. + */
  10583. +static inline gboolean
  10584. +glnx_fstatat_allow_noent (int dfd,
  10585. + const char *path,
  10586. + struct stat *out_buf,
  10587. + int flags,
  10588. + GError **error)
  10589. +{
  10590. + G_GNUC_UNUSED struct stat unused_stbuf;
  10591. + if (TEMP_FAILURE_RETRY (fstatat (dfd, path, out_buf ? out_buf : &unused_stbuf, flags)) != 0)
  10592. + {
  10593. + if (errno != ENOENT)
  10594. + return glnx_throw_errno_prefix (error, "fstatat(%s)", path);
  10595. + /* Note we preserve errno as ENOENT */
  10596. + }
  10597. + else
  10598. + errno = 0;
  10599. + return TRUE;
  10600. +}
  10601. +
  10602. +/**
  10603. + * glnx_renameat:
  10604. + *
  10605. + * Wrapper around renameat() which adds #GError support and ensures that it
  10606. + * retries on %EINTR.
  10607. + */
  10608. +static inline gboolean
  10609. +glnx_renameat (int src_dfd,
  10610. + const gchar *src_path,
  10611. + int dest_dfd,
  10612. + const gchar *dest_path,
  10613. + GError **error)
  10614. +{
  10615. + if (TEMP_FAILURE_RETRY (renameat (src_dfd, src_path, dest_dfd, dest_path)) != 0)
  10616. + return glnx_throw_errno_prefix (error, "renameat(%s, %s)", src_path, dest_path);
  10617. + return TRUE;
  10618. +}
  10619. +
  10620. +/**
  10621. + * glnx_unlinkat:
  10622. + *
  10623. + * Wrapper around unlinkat() which adds #GError support and ensures that it
  10624. + * retries on %EINTR.
  10625. + */
  10626. +static inline gboolean
  10627. +glnx_unlinkat (int dfd,
  10628. + const gchar *path,
  10629. + int flags,
  10630. + GError **error)
  10631. +{
  10632. + if (TEMP_FAILURE_RETRY (unlinkat (dfd, path, flags)) != 0)
  10633. + return glnx_throw_errno_prefix (error, "unlinkat(%s)", path);
  10634. + return TRUE;
  10635. +}
  10636. +
  10637. +G_END_DECLS
  10638. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-local-alloc.c flatpak-1.0.0/libglnx/glnx-local-alloc.c
  10639. --- flatpak-1.0.0.orig/libglnx/glnx-local-alloc.c 1970-01-01 02:00:00.000000000 +0200
  10640. +++ flatpak-1.0.0/libglnx/glnx-local-alloc.c 2018-02-03 21:26:06.308233341 +0300
  10641. @@ -0,0 +1,72 @@
  10642. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  10643. + *
  10644. + * Copyright (C) 2012,2015 Colin Walters <walters@verbum.org>
  10645. + *
  10646. + * This library is free software; you can redistribute it and/or
  10647. + * modify it under the terms of the GNU Lesser General Public
  10648. + * License as published by the Free Software Foundation; either
  10649. + * version 2 of the License, or (at your option) any later version.
  10650. + *
  10651. + * This library is distributed in the hope that it will be useful,
  10652. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10653. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10654. + * Lesser General Public License for more details.
  10655. + *
  10656. + * You should have received a copy of the GNU Lesser General Public
  10657. + * License along with this library; if not, write to the
  10658. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  10659. + * Boston, MA 02111-1307, USA.
  10660. + */
  10661. +
  10662. +#include "config.h"
  10663. +
  10664. +#include "glnx-local-alloc.h"
  10665. +
  10666. +/**
  10667. + * SECTION:glnxlocalalloc
  10668. + * @title: GLnx local allocation
  10669. + * @short_description: Release local variables automatically when they go out of scope
  10670. + *
  10671. + * These macros leverage the GCC extension __attribute__ ((cleanup))
  10672. + * to allow calling a cleanup function such as g_free() when a
  10673. + * variable goes out of scope. See <ulink
  10674. + * url="http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html">
  10675. + * for more information on the attribute.
  10676. + *
  10677. + * The provided macros make it easy to use the cleanup attribute for
  10678. + * types that come with GLib. The primary two are #glnx_free and
  10679. + * #glnx_unref_object, which correspond to g_free() and
  10680. + * g_object_unref(), respectively.
  10681. + *
  10682. + * The rationale behind this is that particularly when handling error
  10683. + * paths, it can be very tricky to ensure the right variables are
  10684. + * freed. With this, one simply applies glnx_unref_object to a
  10685. + * locally-allocated #GFile for example, and it will be automatically
  10686. + * unreferenced when it goes out of scope.
  10687. + *
  10688. + * Note - you should only use these macros for <emphasis>stack
  10689. + * allocated</emphasis> variables. They don't provide garbage
  10690. + * collection or let you avoid freeing things. They're simply a
  10691. + * compiler assisted deterministic mechanism for calling a cleanup
  10692. + * function when a stack frame ends.
  10693. + *
  10694. + * <example id="gs-lfree"><title>Calling g_free automatically</title>
  10695. + * <programlisting>
  10696. + *
  10697. + * GFile *
  10698. + * create_file (GError **error)
  10699. + * {
  10700. + * glnx_free char *random_id = NULL;
  10701. + *
  10702. + * if (!prepare_file (error))
  10703. + * return NULL;
  10704. + *
  10705. + * random_id = alloc_random_id ();
  10706. + *
  10707. + * return create_file_real (error);
  10708. + * // Note that random_id is freed here automatically
  10709. + * }
  10710. + * </programlisting>
  10711. + * </example>
  10712. + *
  10713. + */
  10714. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-local-alloc.h flatpak-1.0.0/libglnx/glnx-local-alloc.h
  10715. --- flatpak-1.0.0.orig/libglnx/glnx-local-alloc.h 1970-01-01 02:00:00.000000000 +0200
  10716. +++ flatpak-1.0.0/libglnx/glnx-local-alloc.h 2018-02-03 21:26:06.308233341 +0300
  10717. @@ -0,0 +1,91 @@
  10718. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  10719. + *
  10720. + * Copyright (C) 2012,2015 Colin Walters <walters@verbum.org>.
  10721. + *
  10722. + * This library is free software; you can redistribute it and/or
  10723. + * modify it under the terms of the GNU Lesser General Public
  10724. + * License as published by the Free Software Foundation; either
  10725. + * version 2 of the License, or (at your option) any later version.
  10726. + *
  10727. + * This library is distributed in the hope that it will be useful,
  10728. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10729. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10730. + * Lesser General Public License for more details.
  10731. + *
  10732. + * You should have received a copy of the GNU Lesser General Public
  10733. + * License along with this library; if not, write to the
  10734. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  10735. + * Boston, MA 02111-1307, USA.
  10736. + */
  10737. +
  10738. +#pragma once
  10739. +
  10740. +#include <gio/gio.h>
  10741. +#include <errno.h>
  10742. +
  10743. +G_BEGIN_DECLS
  10744. +
  10745. +/**
  10746. + * glnx_unref_object:
  10747. + *
  10748. + * Call g_object_unref() on a variable location when it goes out of
  10749. + * scope. Note that unlike g_object_unref(), the variable may be
  10750. + * %NULL.
  10751. + */
  10752. +#define glnx_unref_object __attribute__ ((cleanup(glnx_local_obj_unref)))
  10753. +static inline void
  10754. +glnx_local_obj_unref (void *v)
  10755. +{
  10756. + GObject *o = *(GObject **)v;
  10757. + if (o)
  10758. + g_object_unref (o);
  10759. +}
  10760. +#define glnx_unref_object __attribute__ ((cleanup(glnx_local_obj_unref)))
  10761. +
  10762. +static inline int
  10763. +glnx_steal_fd (int *fdp)
  10764. +{
  10765. + int fd = *fdp;
  10766. + *fdp = -1;
  10767. + return fd;
  10768. +}
  10769. +
  10770. +/**
  10771. + * glnx_close_fd:
  10772. + * @fdp: Pointer to fd
  10773. + *
  10774. + * Effectively `close (glnx_steal_fd (&fd))`. Also
  10775. + * asserts that `close()` did not raise `EBADF` - encountering
  10776. + * that error is usually a critical bug in the program.
  10777. + */
  10778. +static inline void
  10779. +glnx_close_fd (int *fdp)
  10780. +{
  10781. + int errsv;
  10782. +
  10783. + g_assert (fdp);
  10784. +
  10785. + int fd = glnx_steal_fd (fdp);
  10786. + if (fd >= 0)
  10787. + {
  10788. + errsv = errno;
  10789. + if (close (fd) < 0)
  10790. + g_assert (errno != EBADF);
  10791. + errno = errsv;
  10792. + }
  10793. +}
  10794. +
  10795. +/**
  10796. + * glnx_fd_close:
  10797. + *
  10798. + * Deprecated in favor of `glnx_autofd`.
  10799. + */
  10800. +#define glnx_fd_close __attribute__((cleanup(glnx_close_fd)))
  10801. +/**
  10802. + * glnx_autofd:
  10803. + *
  10804. + * Call close() on a variable location when it goes out of scope.
  10805. + */
  10806. +#define glnx_autofd __attribute__((cleanup(glnx_close_fd)))
  10807. +
  10808. +G_END_DECLS
  10809. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-lockfile.c flatpak-1.0.0/libglnx/glnx-lockfile.c
  10810. --- flatpak-1.0.0.orig/libglnx/glnx-lockfile.c 1970-01-01 02:00:00.000000000 +0200
  10811. +++ flatpak-1.0.0/libglnx/glnx-lockfile.c 2018-05-26 00:50:25.434037228 +0300
  10812. @@ -0,0 +1,179 @@
  10813. +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
  10814. +
  10815. +/***
  10816. + This file is part of systemd.
  10817. + Now copied into libglnx:
  10818. + - Use GError
  10819. +
  10820. + Copyright 2010 Lennart Poettering
  10821. + Copyright 2015 Colin Walters <walters@verbum.org>
  10822. +
  10823. + systemd is free software; you can redistribute it and/or modify it
  10824. + under the terms of the GNU Lesser General Public License as published by
  10825. + the Free Software Foundation; either version 2.1 of the License, or
  10826. + (at your option) any later version.
  10827. +
  10828. + systemd is distributed in the hope that it will be useful, but
  10829. + WITHOUT ANY WARRANTY; without even the implied warranty of
  10830. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10831. + Lesser General Public License for more details.
  10832. +
  10833. + You should have received a copy of the GNU Lesser General Public License
  10834. + along with systemd; If not, see <http://www.gnu.org/licenses/>.
  10835. +***/
  10836. +
  10837. +#include "config.h"
  10838. +
  10839. +#include <stdlib.h>
  10840. +#include <stdbool.h>
  10841. +#include <errno.h>
  10842. +#include <string.h>
  10843. +#include <stdio.h>
  10844. +#include <limits.h>
  10845. +#include <unistd.h>
  10846. +#include <sys/types.h>
  10847. +#include <sys/file.h>
  10848. +#include <sys/stat.h>
  10849. +#include <fcntl.h>
  10850. +
  10851. +#include "glnx-lockfile.h"
  10852. +#include "glnx-errors.h"
  10853. +#include "glnx-fdio.h"
  10854. +#include "glnx-backport-autocleanups.h"
  10855. +#include "glnx-local-alloc.h"
  10856. +
  10857. +#define newa(t, n) ((t*) alloca(sizeof(t)*(n)))
  10858. +
  10859. +/**
  10860. + * glnx_make_lock_file:
  10861. + * @dfd: Directory file descriptor (if not `AT_FDCWD`, must have lifetime `>=` @out_lock)
  10862. + * @p: Path
  10863. + * @operation: one of `LOCK_SH`, `LOCK_EX`, `LOCK_UN`, as passed to flock()
  10864. + * @out_lock: (out) (caller allocates): Return location for lock
  10865. + * @error: Error
  10866. + *
  10867. + * Block until a lock file named @p (relative to @dfd) can be created,
  10868. + * using the flags in @operation, returning the lock data in the
  10869. + * caller-allocated location @out_lock.
  10870. + *
  10871. + * This API wraps new-style process locking if available, otherwise
  10872. + * falls back to BSD locks.
  10873. + */
  10874. +gboolean
  10875. +glnx_make_lock_file(int dfd, const char *p, int operation, GLnxLockFile *out_lock, GError **error) {
  10876. + glnx_autofd int fd = -1;
  10877. + g_autofree char *t = NULL;
  10878. + int r;
  10879. +
  10880. + /*
  10881. + * We use UNPOSIX locks if they are available. They have nice
  10882. + * semantics, and are mostly compatible with NFS. However,
  10883. + * they are only available on new kernels. When we detect we
  10884. + * are running on an older kernel, then we fall back to good
  10885. + * old BSD locks. They also have nice semantics, but are
  10886. + * slightly problematic on NFS, where they are upgraded to
  10887. + * POSIX locks, even though locally they are orthogonal to
  10888. + * POSIX locks.
  10889. + */
  10890. +
  10891. + t = g_strdup(p);
  10892. +
  10893. + for (;;) {
  10894. +#ifdef F_OFD_SETLK
  10895. + struct flock fl = {
  10896. + .l_type = (operation & ~LOCK_NB) == LOCK_EX ? F_WRLCK : F_RDLCK,
  10897. + .l_whence = SEEK_SET,
  10898. + };
  10899. +#endif
  10900. + struct stat st;
  10901. +
  10902. + fd = openat(dfd, p, O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY, 0600);
  10903. + if (fd < 0)
  10904. + return glnx_throw_errno(error);
  10905. +
  10906. + /* Unfortunately, new locks are not in RHEL 7.1 glibc */
  10907. +#ifdef F_OFD_SETLK
  10908. + r = fcntl(fd, (operation & LOCK_NB) ? F_OFD_SETLK : F_OFD_SETLKW, &fl);
  10909. +#else
  10910. + r = -1;
  10911. + errno = EINVAL;
  10912. +#endif
  10913. + if (r < 0) {
  10914. +
  10915. + /* If the kernel is too old, use good old BSD locks */
  10916. + if (errno == EINVAL)
  10917. + r = flock(fd, operation);
  10918. +
  10919. + if (r < 0)
  10920. + return glnx_throw_errno_prefix (error, "flock");
  10921. + }
  10922. +
  10923. + /* If we acquired the lock, let's check if the file
  10924. + * still exists in the file system. If not, then the
  10925. + * previous exclusive owner removed it and then closed
  10926. + * it. In such a case our acquired lock is worthless,
  10927. + * hence try again. */
  10928. +
  10929. + if (!glnx_fstat (fd, &st, error))
  10930. + return FALSE;
  10931. + if (st.st_nlink > 0)
  10932. + break;
  10933. +
  10934. + glnx_close_fd (&fd);
  10935. + }
  10936. +
  10937. + /* Note that if this is not AT_FDCWD, the caller takes responsibility
  10938. + * for the fd's lifetime being >= that of the lock.
  10939. + */
  10940. + out_lock->initialized = TRUE;
  10941. + out_lock->dfd = dfd;
  10942. + out_lock->path = g_steal_pointer (&t);
  10943. + out_lock->fd = glnx_steal_fd (&fd);
  10944. + out_lock->operation = operation;
  10945. + return TRUE;
  10946. +}
  10947. +
  10948. +void glnx_release_lock_file(GLnxLockFile *f) {
  10949. + int r;
  10950. +
  10951. + if (!(f && f->initialized))
  10952. + return;
  10953. +
  10954. + if (f->path) {
  10955. +
  10956. + /* If we are the exclusive owner we can safely delete
  10957. + * the lock file itself. If we are not the exclusive
  10958. + * owner, we can try becoming it. */
  10959. +
  10960. + if (f->fd >= 0 &&
  10961. + (f->operation & ~LOCK_NB) == LOCK_SH) {
  10962. +#ifdef F_OFD_SETLK
  10963. + static const struct flock fl = {
  10964. + .l_type = F_WRLCK,
  10965. + .l_whence = SEEK_SET,
  10966. + };
  10967. +
  10968. + r = fcntl(f->fd, F_OFD_SETLK, &fl);
  10969. +#else
  10970. + r = -1;
  10971. + errno = EINVAL;
  10972. +#endif
  10973. + if (r < 0 && errno == EINVAL)
  10974. + r = flock(f->fd, LOCK_EX|LOCK_NB);
  10975. +
  10976. + if (r >= 0)
  10977. + f->operation = LOCK_EX|LOCK_NB;
  10978. + }
  10979. +
  10980. + if ((f->operation & ~LOCK_NB) == LOCK_EX) {
  10981. + (void) unlinkat(f->dfd, f->path, 0);
  10982. + }
  10983. +
  10984. + g_free(f->path);
  10985. + f->path = NULL;
  10986. + }
  10987. +
  10988. + glnx_close_fd (&f->fd);
  10989. + f->operation = 0;
  10990. + f->initialized = FALSE;
  10991. +}
  10992. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-lockfile.h flatpak-1.0.0/libglnx/glnx-lockfile.h
  10993. --- flatpak-1.0.0.orig/libglnx/glnx-lockfile.h 1970-01-01 02:00:00.000000000 +0200
  10994. +++ flatpak-1.0.0/libglnx/glnx-lockfile.h 2018-02-03 21:26:06.309233341 +0300
  10995. @@ -0,0 +1,40 @@
  10996. +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
  10997. +
  10998. +#pragma once
  10999. +
  11000. +/***
  11001. + This file is part of systemd.
  11002. +
  11003. + Copyright 2011 Lennart Poettering
  11004. + Copyright 2015 Colin Walters <walters@verbum.org>
  11005. +
  11006. + systemd is free software; you can redistribute it and/or modify it
  11007. + under the terms of the GNU Lesser General Public License as published by
  11008. + the Free Software Foundation; either version 2.1 of the License, or
  11009. + (at your option) any later version.
  11010. +
  11011. + systemd is distributed in the hope that it will be useful, but
  11012. + WITHOUT ANY WARRANTY; without even the implied warranty of
  11013. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11014. + Lesser General Public License for more details.
  11015. +
  11016. + You should have received a copy of the GNU Lesser General Public License
  11017. + along with systemd; If not, see <http://www.gnu.org/licenses/>.
  11018. +***/
  11019. +
  11020. +#include "config.h"
  11021. +
  11022. +#include "glnx-backport-autoptr.h"
  11023. +
  11024. +typedef struct GLnxLockFile {
  11025. + gboolean initialized;
  11026. + int dfd;
  11027. + char *path;
  11028. + int fd;
  11029. + int operation;
  11030. +} GLnxLockFile;
  11031. +
  11032. +gboolean glnx_make_lock_file(int dfd, const char *p, int operation, GLnxLockFile *ret, GError **error);
  11033. +void glnx_release_lock_file(GLnxLockFile *f);
  11034. +
  11035. +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(GLnxLockFile, glnx_release_lock_file)
  11036. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-macros.h flatpak-1.0.0/libglnx/glnx-macros.h
  11037. --- flatpak-1.0.0.orig/libglnx/glnx-macros.h 1970-01-01 02:00:00.000000000 +0200
  11038. +++ flatpak-1.0.0/libglnx/glnx-macros.h 2018-02-03 21:26:06.309233341 +0300
  11039. @@ -0,0 +1,189 @@
  11040. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  11041. + *
  11042. + * Copyright (C) 2017 Colin Walters <walters@verbum.org>
  11043. + * With original source from systemd:
  11044. + * Copyright 2010 Lennart Poettering
  11045. + *
  11046. + * This library is free software; you can redistribute it and/or
  11047. + * modify it under the terms of the GNU Lesser General Public
  11048. + * License as published by the Free Software Foundation; either
  11049. + * version 2 of the License, or (at your option) any later version.
  11050. + *
  11051. + * This library is distributed in the hope that it will be useful,
  11052. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11053. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11054. + * Lesser General Public License for more details.
  11055. + *
  11056. + * You should have received a copy of the GNU Lesser General Public
  11057. + * License along with this library; if not, write to the
  11058. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  11059. + * Boston, MA 02111-1307, USA.
  11060. + */
  11061. +
  11062. +#pragma once
  11063. +
  11064. +#include <stdlib.h>
  11065. +#include <string.h>
  11066. +#include <gio/gio.h>
  11067. +
  11068. +G_BEGIN_DECLS
  11069. +
  11070. +/* All of these are for C only. */
  11071. +#ifndef __GI_SCANNER__
  11072. +
  11073. +/* Taken from https://github.com/systemd/systemd/src/basic/string-util.h
  11074. + * at revision v228-666-gcf6c8c4
  11075. + */
  11076. +#define glnx_strjoina(a, ...) \
  11077. + ({ \
  11078. + const char *_appendees_[] = { a, __VA_ARGS__ }; \
  11079. + char *_d_, *_p_; \
  11080. + size_t _len_ = 0; \
  11081. + unsigned _i_; \
  11082. + for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
  11083. + _len_ += strlen(_appendees_[_i_]); \
  11084. + _p_ = _d_ = alloca(_len_ + 1); \
  11085. + for (_i_ = 0; _i_ < G_N_ELEMENTS(_appendees_) && _appendees_[_i_]; _i_++) \
  11086. + _p_ = stpcpy(_p_, _appendees_[_i_]); \
  11087. + *_p_ = 0; \
  11088. + _d_; \
  11089. + })
  11090. +
  11091. +#ifndef G_IN_SET
  11092. +
  11093. +/* Infrastructure for `G_IN_SET`; this code is copied from
  11094. + * systemd's macro.h - please treat that version as canonical
  11095. + * and submit patches first to systemd.
  11096. + */
  11097. +#define _G_INSET_CASE_F(X) case X:
  11098. +#define _G_INSET_CASE_F_1(CASE, X) _G_INSET_CASE_F(X)
  11099. +#define _G_INSET_CASE_F_2(CASE, X, ...) CASE(X) _G_INSET_CASE_F_1(CASE, __VA_ARGS__)
  11100. +#define _G_INSET_CASE_F_3(CASE, X, ...) CASE(X) _G_INSET_CASE_F_2(CASE, __VA_ARGS__)
  11101. +#define _G_INSET_CASE_F_4(CASE, X, ...) CASE(X) _G_INSET_CASE_F_3(CASE, __VA_ARGS__)
  11102. +#define _G_INSET_CASE_F_5(CASE, X, ...) CASE(X) _G_INSET_CASE_F_4(CASE, __VA_ARGS__)
  11103. +#define _G_INSET_CASE_F_6(CASE, X, ...) CASE(X) _G_INSET_CASE_F_5(CASE, __VA_ARGS__)
  11104. +#define _G_INSET_CASE_F_7(CASE, X, ...) CASE(X) _G_INSET_CASE_F_6(CASE, __VA_ARGS__)
  11105. +#define _G_INSET_CASE_F_8(CASE, X, ...) CASE(X) _G_INSET_CASE_F_7(CASE, __VA_ARGS__)
  11106. +#define _G_INSET_CASE_F_9(CASE, X, ...) CASE(X) _G_INSET_CASE_F_8(CASE, __VA_ARGS__)
  11107. +#define _G_INSET_CASE_F_10(CASE, X, ...) CASE(X) _G_INSET_CASE_F_9(CASE, __VA_ARGS__)
  11108. +#define _G_INSET_CASE_F_11(CASE, X, ...) CASE(X) _G_INSET_CASE_F_10(CASE, __VA_ARGS__)
  11109. +#define _G_INSET_CASE_F_12(CASE, X, ...) CASE(X) _G_INSET_CASE_F_11(CASE, __VA_ARGS__)
  11110. +#define _G_INSET_CASE_F_13(CASE, X, ...) CASE(X) _G_INSET_CASE_F_12(CASE, __VA_ARGS__)
  11111. +#define _G_INSET_CASE_F_14(CASE, X, ...) CASE(X) _G_INSET_CASE_F_13(CASE, __VA_ARGS__)
  11112. +#define _G_INSET_CASE_F_15(CASE, X, ...) CASE(X) _G_INSET_CASE_F_14(CASE, __VA_ARGS__)
  11113. +#define _G_INSET_CASE_F_16(CASE, X, ...) CASE(X) _G_INSET_CASE_F_15(CASE, __VA_ARGS__)
  11114. +#define _G_INSET_CASE_F_17(CASE, X, ...) CASE(X) _G_INSET_CASE_F_16(CASE, __VA_ARGS__)
  11115. +#define _G_INSET_CASE_F_18(CASE, X, ...) CASE(X) _G_INSET_CASE_F_17(CASE, __VA_ARGS__)
  11116. +#define _G_INSET_CASE_F_19(CASE, X, ...) CASE(X) _G_INSET_CASE_F_18(CASE, __VA_ARGS__)
  11117. +#define _G_INSET_CASE_F_20(CASE, X, ...) CASE(X) _G_INSET_CASE_F_19(CASE, __VA_ARGS__)
  11118. +
  11119. +#define _G_INSET_GET_CASE_F(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,NAME,...) NAME
  11120. +#define _G_INSET_FOR_EACH_MAKE_CASE(...) \
  11121. + _G_INSET_GET_CASE_F(__VA_ARGS__,_G_INSET_CASE_F_20,_G_INSET_CASE_F_19,_G_INSET_CASE_F_18,_G_INSET_CASE_F_17,_G_INSET_CASE_F_16,_G_INSET_CASE_F_15,_G_INSET_CASE_F_14,_G_INSET_CASE_F_13,_G_INSET_CASE_F_12,_G_INSET_CASE_F_11, \
  11122. + _G_INSET_CASE_F_10,_G_INSET_CASE_F_9,_G_INSET_CASE_F_8,_G_INSET_CASE_F_7,_G_INSET_CASE_F_6,_G_INSET_CASE_F_5,_G_INSET_CASE_F_4,_G_INSET_CASE_F_3,_G_INSET_CASE_F_2,_G_INSET_CASE_F_1) \
  11123. + (_G_INSET_CASE_F,__VA_ARGS__)
  11124. +
  11125. +/* Note: claiming the name here even though it isn't upstream yet
  11126. + * https://bugzilla.gnome.org/show_bug.cgi?id=783751
  11127. + */
  11128. +/**
  11129. + * G_IN_SET:
  11130. + * @x: Integer (or smaller) sized value
  11131. + * @...: Elements to compare
  11132. + *
  11133. + * It's quite common to test whether or not `char` values or Unix @errno (among) others
  11134. + * are members of a small set. Normally one has to choose to either use `if (x == val || x == otherval ...)`
  11135. + * or a `switch` statement. This macro is useful to reduce duplication in the first case,
  11136. + * where one can write simply `if (G_IN_SET (x, val, otherval))`, and avoid the verbosity
  11137. + * that the `switch` statement requires.
  11138. + */
  11139. +#define G_IN_SET(x, ...) \
  11140. + ({ \
  11141. + gboolean _g_inset_found = FALSE; \
  11142. + /* If the build breaks in the line below, you need to extend the case macros */ \
  11143. + static G_GNUC_UNUSED char _static_assert__macros_need_to_be_extended[20 - sizeof((int[]){__VA_ARGS__})/sizeof(int)]; \
  11144. + switch(x) { \
  11145. + _G_INSET_FOR_EACH_MAKE_CASE(__VA_ARGS__) \
  11146. + _g_inset_found = TRUE; \
  11147. + break; \
  11148. + default: \
  11149. + break; \
  11150. + } \
  11151. + _g_inset_found; \
  11152. + })
  11153. +
  11154. +#endif /* ifndef G_IN_SET */
  11155. +
  11156. +#define _GLNX_CONCAT(a, b) a##b
  11157. +#define _GLNX_CONCAT_INDIRECT(a, b) _GLNX_CONCAT(a, b)
  11158. +#define _GLNX_MAKE_ANONYMOUS(a) _GLNX_CONCAT_INDIRECT(a, __COUNTER__)
  11159. +
  11160. +#define _GLNX_HASH_TABLE_FOREACH_IMPL_KV(guard, ht, it, kt, k, vt, v) \
  11161. + gboolean guard = TRUE; \
  11162. + G_STATIC_ASSERT (sizeof (kt) == sizeof (void*)); \
  11163. + G_STATIC_ASSERT (sizeof (vt) == sizeof (void*)); \
  11164. + for (GHashTableIter it; \
  11165. + guard && ({ g_hash_table_iter_init (&it, ht), TRUE; }); \
  11166. + guard = FALSE) \
  11167. + for (kt k; guard; guard = FALSE) \
  11168. + for (vt v; g_hash_table_iter_next (&it, (gpointer)&k, (gpointer)&v);)
  11169. +
  11170. +
  11171. +/* Cleaner method to iterate over a GHashTable. I.e. rather than
  11172. + *
  11173. + * gpointer k, v;
  11174. + * GHashTableIter it;
  11175. + * g_hash_table_iter_init (&it, table);
  11176. + * while (g_hash_table_iter_next (&it, &k, &v))
  11177. + * {
  11178. + * const char *str = k;
  11179. + * GPtrArray *arr = v;
  11180. + * ...
  11181. + * }
  11182. + *
  11183. + * you can simply do
  11184. + *
  11185. + * GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, str, GPtrArray*, arr)
  11186. + * {
  11187. + * ...
  11188. + * }
  11189. + *
  11190. + * All variables are scoped within the loop. You may use the `it` variable as
  11191. + * usual, e.g. to remove an element using g_hash_table_iter_remove(&it). There
  11192. + * are shorter variants for the more common cases where you do not need access
  11193. + * to the iterator or to keys/values:
  11194. + *
  11195. + * GLNX_HASH_TABLE_FOREACH (table, const char*, str) { ... }
  11196. + * GLNX_HASH_TABLE_FOREACH_V (table, MyData*, data) { ... }
  11197. + * GLNX_HASH_TABLE_FOREACH_KV (table, const char*, str, MyData*, data) { ... }
  11198. + *
  11199. + */
  11200. +#define GLNX_HASH_TABLE_FOREACH_IT(ht, it, kt, k, vt, v) \
  11201. + _GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
  11202. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, it, kt, k, vt, v)
  11203. +
  11204. +/* Variant of GLNX_HASH_TABLE_FOREACH without having to specify an iterator. An
  11205. + * anonymous iterator will be created. */
  11206. +#define GLNX_HASH_TABLE_FOREACH_KV(ht, kt, k, vt, v) \
  11207. + _GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
  11208. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
  11209. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), kt, k, vt, v)
  11210. +
  11211. +/* Variant of GLNX_HASH_TABLE_FOREACH_KV which omits unpacking keys. */
  11212. +#define GLNX_HASH_TABLE_FOREACH_V(ht, vt, v) \
  11213. + _GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
  11214. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
  11215. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), \
  11216. + gpointer, _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_v_), \
  11217. + vt, v)
  11218. +
  11219. +/* Variant of GLNX_HASH_TABLE_FOREACH_KV which omits unpacking vals. */
  11220. +#define GLNX_HASH_TABLE_FOREACH(ht, kt, k) \
  11221. + _GLNX_HASH_TABLE_FOREACH_IMPL_KV( \
  11222. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_guard_), ht, \
  11223. + _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_it_), kt, k, \
  11224. + gpointer, _GLNX_MAKE_ANONYMOUS(_glnx_ht_iter_v_))
  11225. +
  11226. +#endif /* GI_SCANNER */
  11227. +
  11228. +G_END_DECLS
  11229. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-missing.h flatpak-1.0.0/libglnx/glnx-missing.h
  11230. --- flatpak-1.0.0.orig/libglnx/glnx-missing.h 1970-01-01 02:00:00.000000000 +0200
  11231. +++ flatpak-1.0.0/libglnx/glnx-missing.h 2018-02-03 21:26:06.309233341 +0300
  11232. @@ -0,0 +1,95 @@
  11233. +#pragma once
  11234. +
  11235. +/***
  11236. + This file was originally part of systemd.
  11237. +
  11238. + Copyright 2010 Lennart Poettering
  11239. +
  11240. + systemd is free software; you can redistribute it and/or modify it
  11241. + under the terms of the GNU Lesser General Public License as published by
  11242. + the Free Software Foundation; either version 2.1 of the License, or
  11243. + (at your option) any later version.
  11244. +
  11245. + systemd is distributed in the hope that it will be useful, but
  11246. + WITHOUT ANY WARRANTY; without even the implied warranty of
  11247. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11248. + Lesser General Public License for more details.
  11249. +
  11250. + You should have received a copy of the GNU Lesser General Public License
  11251. + along with systemd; If not, see <http://www.gnu.org/licenses/>.
  11252. +***/
  11253. +
  11254. +/* Missing glibc definitions to access certain kernel APIs.
  11255. + This file is last updated from systemd git:
  11256. +
  11257. + commit 71e5200f94b22589922704aa4abdf95d4fe2e528
  11258. + Author: Daniel Mack <daniel@zonque.org>
  11259. + AuthorDate: Tue Oct 18 17:57:10 2016 +0200
  11260. + Commit: Lennart Poettering <lennart@poettering.net>
  11261. + CommitDate: Fri Sep 22 15:24:54 2017 +0200
  11262. +
  11263. + Add abstraction model for BPF programs
  11264. +*/
  11265. +
  11266. +#include <errno.h>
  11267. +#include <fcntl.h>
  11268. +#include <stdlib.h>
  11269. +#include <sys/resource.h>
  11270. +#include <sys/syscall.h>
  11271. +#include <uchar.h>
  11272. +#include <unistd.h>
  11273. +
  11274. +/* The precise definition of __O_TMPFILE is arch specific; use the
  11275. + * values defined by the kernel (note: some are hexa, some are octal,
  11276. + * duplicated as-is from the kernel definitions):
  11277. + * - alpha, parisc, sparc: each has a specific value;
  11278. + * - others: they use the "generic" value.
  11279. + */
  11280. +
  11281. +#ifndef __O_TMPFILE
  11282. +#if defined(__alpha__)
  11283. +#define __O_TMPFILE 0100000000
  11284. +#elif defined(__parisc__) || defined(__hppa__)
  11285. +#define __O_TMPFILE 0400000000
  11286. +#elif defined(__sparc__) || defined(__sparc64__)
  11287. +#define __O_TMPFILE 0x2000000
  11288. +#else
  11289. +#define __O_TMPFILE 020000000
  11290. +#endif
  11291. +#endif
  11292. +
  11293. +/* a horrid kludge trying to make sure that this will fail on old kernels */
  11294. +#ifndef O_TMPFILE
  11295. +#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
  11296. +#endif
  11297. +
  11298. +#ifndef RENAME_NOREPLACE
  11299. +#define RENAME_NOREPLACE (1 << 0)
  11300. +#endif
  11301. +#ifndef RENAME_EXCHANGE
  11302. +#define RENAME_EXCHANGE (1 << 1)
  11303. +#endif
  11304. +
  11305. +#ifndef F_LINUX_SPECIFIC_BASE
  11306. +#define F_LINUX_SPECIFIC_BASE 1024
  11307. +#endif
  11308. +
  11309. +#ifndef F_ADD_SEALS
  11310. +#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
  11311. +#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
  11312. +
  11313. +#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
  11314. +#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
  11315. +#define F_SEAL_GROW 0x0004 /* prevent file from growing */
  11316. +#define F_SEAL_WRITE 0x0008 /* prevent writes */
  11317. +#endif
  11318. +
  11319. +#ifndef MFD_ALLOW_SEALING
  11320. +#define MFD_ALLOW_SEALING 0x0002U
  11321. +#endif
  11322. +
  11323. +#ifndef MFD_CLOEXEC
  11324. +#define MFD_CLOEXEC 0x0001U
  11325. +#endif
  11326. +
  11327. +#include "glnx-missing-syscall.h"
  11328. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-missing-syscall.h flatpak-1.0.0/libglnx/glnx-missing-syscall.h
  11329. --- flatpak-1.0.0.orig/libglnx/glnx-missing-syscall.h 1970-01-01 02:00:00.000000000 +0200
  11330. +++ flatpak-1.0.0/libglnx/glnx-missing-syscall.h 2018-05-26 00:50:25.434037228 +0300
  11331. @@ -0,0 +1,154 @@
  11332. +/***
  11333. + This file was originally part of systemd.
  11334. +
  11335. + Copyright 2010 Lennart Poettering
  11336. + Copyright 2016 Zbigniew Jędrzejewski-Szmek
  11337. +
  11338. + systemd is free software; you can redistribute it and/or modify it
  11339. + under the terms of the GNU Lesser General Public License as published by
  11340. + the Free Software Foundation; either version 2.1 of the License, or
  11341. + (at your option) any later version.
  11342. +
  11343. + systemd is distributed in the hope that it will be useful, but
  11344. + WITHOUT ANY WARRANTY; without even the implied warranty of
  11345. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11346. + Lesser General Public License for more details.
  11347. +
  11348. + You should have received a copy of the GNU Lesser General Public License
  11349. + along with systemd; If not, see <http://www.gnu.org/licenses/>.
  11350. +***/
  11351. +
  11352. +/* Missing glibc definitions to access certain kernel APIs.
  11353. + This file is last updated from systemd git:
  11354. +
  11355. + commit 71e5200f94b22589922704aa4abdf95d4fe2e528
  11356. + Author: Daniel Mack <daniel@zonque.org>
  11357. + AuthorDate: Tue Oct 18 17:57:10 2016 +0200
  11358. + Commit: Lennart Poettering <lennart@poettering.net>
  11359. + CommitDate: Fri Sep 22 15:24:54 2017 +0200
  11360. +
  11361. + Add abstraction model for BPF programs
  11362. +*/
  11363. +
  11364. +#include "config.h"
  11365. +
  11366. +#if !HAVE_DECL_RENAMEAT2
  11367. +# ifndef __NR_renameat2
  11368. +# if defined __x86_64__
  11369. +# define __NR_renameat2 316
  11370. +# elif defined __arm__
  11371. +# define __NR_renameat2 382
  11372. +# elif defined __aarch64__
  11373. +# define __NR_renameat2 276
  11374. +# elif defined _MIPS_SIM
  11375. +# if _MIPS_SIM == _MIPS_SIM_ABI32
  11376. +# define __NR_renameat2 4351
  11377. +# endif
  11378. +# if _MIPS_SIM == _MIPS_SIM_NABI32
  11379. +# define __NR_renameat2 6315
  11380. +# endif
  11381. +# if _MIPS_SIM == _MIPS_SIM_ABI64
  11382. +# define __NR_renameat2 5311
  11383. +# endif
  11384. +# elif defined __i386__
  11385. +# define __NR_renameat2 353
  11386. +# elif defined __powerpc64__
  11387. +# define __NR_renameat2 357
  11388. +# elif defined __s390__ || defined __s390x__
  11389. +# define __NR_renameat2 347
  11390. +# elif defined __arc__
  11391. +# define __NR_renameat2 276
  11392. +# else
  11393. +# warning "__NR_renameat2 unknown for your architecture"
  11394. +# endif
  11395. +# endif
  11396. +
  11397. +static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
  11398. +# ifdef __NR_renameat2
  11399. + return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags);
  11400. +# else
  11401. + errno = ENOSYS;
  11402. + return -1;
  11403. +# endif
  11404. +}
  11405. +#endif
  11406. +
  11407. +#if !HAVE_DECL_MEMFD_CREATE
  11408. +# ifndef __NR_memfd_create
  11409. +# if defined __x86_64__
  11410. +# define __NR_memfd_create 319
  11411. +# elif defined __arm__
  11412. +# define __NR_memfd_create 385
  11413. +# elif defined __aarch64__
  11414. +# define __NR_memfd_create 279
  11415. +# elif defined __s390__
  11416. +# define __NR_memfd_create 350
  11417. +# elif defined _MIPS_SIM
  11418. +# if _MIPS_SIM == _MIPS_SIM_ABI32
  11419. +# define __NR_memfd_create 4354
  11420. +# endif
  11421. +# if _MIPS_SIM == _MIPS_SIM_NABI32
  11422. +# define __NR_memfd_create 6318
  11423. +# endif
  11424. +# if _MIPS_SIM == _MIPS_SIM_ABI64
  11425. +# define __NR_memfd_create 5314
  11426. +# endif
  11427. +# elif defined __i386__
  11428. +# define __NR_memfd_create 356
  11429. +# elif defined __arc__
  11430. +# define __NR_memfd_create 279
  11431. +# else
  11432. +# warning "__NR_memfd_create unknown for your architecture"
  11433. +# endif
  11434. +# endif
  11435. +
  11436. +static inline int memfd_create(const char *name, unsigned int flags) {
  11437. +# ifdef __NR_memfd_create
  11438. + return syscall(__NR_memfd_create, name, flags);
  11439. +# else
  11440. + errno = ENOSYS;
  11441. + return -1;
  11442. +# endif
  11443. +}
  11444. +#endif
  11445. +
  11446. +/* Copied from systemd git:
  11447. + commit 6bda23dd6aaba50cf8e3e6024248cf736cc443ca
  11448. + Author: Yu Watanabe <watanabe.yu+github@gmail.com>
  11449. + AuthorDate: Thu Jul 27 20:22:54 2017 +0900
  11450. + Commit: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
  11451. + CommitDate: Thu Jul 27 07:22:54 2017 -0400
  11452. +*/
  11453. +#if !HAVE_DECL_COPY_FILE_RANGE
  11454. +# ifndef __NR_copy_file_range
  11455. +# if defined(__x86_64__)
  11456. +# define __NR_copy_file_range 326
  11457. +# elif defined(__i386__)
  11458. +# define __NR_copy_file_range 377
  11459. +# elif defined __s390__
  11460. +# define __NR_copy_file_range 375
  11461. +# elif defined __arm__
  11462. +# define __NR_copy_file_range 391
  11463. +# elif defined __aarch64__
  11464. +# define __NR_copy_file_range 285
  11465. +# elif defined __powerpc__
  11466. +# define __NR_copy_file_range 379
  11467. +# elif defined __arc__
  11468. +# define __NR_copy_file_range 285
  11469. +# else
  11470. +# warning "__NR_copy_file_range not defined for your architecture"
  11471. +# endif
  11472. +# endif
  11473. +
  11474. +static inline ssize_t copy_file_range(int fd_in, loff_t *off_in,
  11475. + int fd_out, loff_t *off_out,
  11476. + size_t len,
  11477. + unsigned int flags) {
  11478. +# ifdef __NR_copy_file_range
  11479. + return syscall(__NR_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
  11480. +# else
  11481. + errno = ENOSYS;
  11482. + return -1;
  11483. +# endif
  11484. +}
  11485. +#endif
  11486. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-shutil.c flatpak-1.0.0/libglnx/glnx-shutil.c
  11487. --- flatpak-1.0.0.orig/libglnx/glnx-shutil.c 1970-01-01 02:00:00.000000000 +0200
  11488. +++ flatpak-1.0.0/libglnx/glnx-shutil.c 2018-05-26 00:50:25.434037228 +0300
  11489. @@ -0,0 +1,260 @@
  11490. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  11491. + *
  11492. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  11493. + *
  11494. + * This library is free software; you can redistribute it and/or
  11495. + * modify it under the terms of the GNU Lesser General Public
  11496. + * License as published by the Free Software Foundation; either
  11497. + * version 2 of the License, or (at your option) any later version.
  11498. + *
  11499. + * This library is distributed in the hope that it will be useful,
  11500. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11501. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11502. + * Lesser General Public License for more details.
  11503. + *
  11504. + * You should have received a copy of the GNU Lesser General Public
  11505. + * License along with this library; if not, write to the
  11506. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  11507. + * Boston, MA 02111-1307, USA.
  11508. + */
  11509. +
  11510. +#include "config.h"
  11511. +
  11512. +#include <string.h>
  11513. +
  11514. +#include <glnx-shutil.h>
  11515. +#include <glnx-errors.h>
  11516. +#include <glnx-local-alloc.h>
  11517. +
  11518. +static gboolean
  11519. +glnx_shutil_rm_rf_children (GLnxDirFdIterator *dfd_iter,
  11520. + GCancellable *cancellable,
  11521. + GError **error)
  11522. +{
  11523. + struct dirent *dent;
  11524. +
  11525. + while (TRUE)
  11526. + {
  11527. + if (!glnx_dirfd_iterator_next_dent_ensure_dtype (dfd_iter, &dent, cancellable, error))
  11528. + return FALSE;
  11529. + if (dent == NULL)
  11530. + break;
  11531. +
  11532. + if (dent->d_type == DT_DIR)
  11533. + {
  11534. + g_auto(GLnxDirFdIterator) child_dfd_iter = { 0, };
  11535. +
  11536. + if (!glnx_dirfd_iterator_init_at (dfd_iter->fd, dent->d_name, FALSE,
  11537. + &child_dfd_iter, error))
  11538. + return FALSE;
  11539. +
  11540. + if (!glnx_shutil_rm_rf_children (&child_dfd_iter, cancellable, error))
  11541. + return FALSE;
  11542. +
  11543. + if (unlinkat (dfd_iter->fd, dent->d_name, AT_REMOVEDIR) == -1)
  11544. + return glnx_throw_errno_prefix (error, "unlinkat");
  11545. + }
  11546. + else
  11547. + {
  11548. + if (unlinkat (dfd_iter->fd, dent->d_name, 0) == -1)
  11549. + {
  11550. + if (errno != ENOENT)
  11551. + return glnx_throw_errno_prefix (error, "unlinkat");
  11552. + }
  11553. + }
  11554. + }
  11555. +
  11556. + return TRUE;
  11557. +}
  11558. +
  11559. +/**
  11560. + * glnx_shutil_rm_rf_at:
  11561. + * @dfd: A directory file descriptor, or `AT_FDCWD` or `-1` for current
  11562. + * @path: Path
  11563. + * @cancellable: Cancellable
  11564. + * @error: Error
  11565. + *
  11566. + * Recursively delete the filename referenced by the combination of
  11567. + * the directory fd @dfd and @path; it may be a file or directory. No
  11568. + * error is thrown if @path does not exist.
  11569. + */
  11570. +gboolean
  11571. +glnx_shutil_rm_rf_at (int dfd,
  11572. + const char *path,
  11573. + GCancellable *cancellable,
  11574. + GError **error)
  11575. +{
  11576. + dfd = glnx_dirfd_canonicalize (dfd);
  11577. +
  11578. +
  11579. + /* With O_NOFOLLOW first */
  11580. + glnx_autofd int target_dfd =
  11581. + openat (dfd, path, O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC | O_NOFOLLOW);
  11582. +
  11583. + if (target_dfd == -1)
  11584. + {
  11585. + int errsv = errno;
  11586. + if (errsv == ENOENT)
  11587. + {
  11588. + ;
  11589. + }
  11590. + else if (errsv == ENOTDIR || errsv == ELOOP)
  11591. + {
  11592. + if (unlinkat (dfd, path, 0) != 0)
  11593. + return glnx_throw_errno_prefix (error, "unlinkat");
  11594. + }
  11595. + else
  11596. + return glnx_throw_errno_prefix (error, "open(%s)", path);
  11597. + }
  11598. + else
  11599. + {
  11600. + g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
  11601. + if (!glnx_dirfd_iterator_init_take_fd (&target_dfd, &dfd_iter, error))
  11602. + return FALSE;
  11603. +
  11604. + if (!glnx_shutil_rm_rf_children (&dfd_iter, cancellable, error))
  11605. + return FALSE;
  11606. +
  11607. + if (unlinkat (dfd, path, AT_REMOVEDIR) == -1)
  11608. + {
  11609. + if (errno != ENOENT)
  11610. + return glnx_throw_errno_prefix (error, "unlinkat");
  11611. + }
  11612. + }
  11613. +
  11614. + return TRUE;
  11615. +}
  11616. +
  11617. +static gboolean
  11618. +mkdir_p_at_internal (int dfd,
  11619. + char *path,
  11620. + int mode,
  11621. + GCancellable *cancellable,
  11622. + GError **error)
  11623. +{
  11624. + gboolean did_recurse = FALSE;
  11625. +
  11626. + if (g_cancellable_set_error_if_cancelled (cancellable, error))
  11627. + return FALSE;
  11628. +
  11629. + again:
  11630. + if (mkdirat (dfd, path, mode) == -1)
  11631. + {
  11632. + if (errno == ENOENT)
  11633. + {
  11634. + char *lastslash;
  11635. +
  11636. + g_assert (!did_recurse);
  11637. +
  11638. + lastslash = strrchr (path, '/');
  11639. + if (lastslash == NULL)
  11640. + {
  11641. + /* This can happen if @dfd was deleted between being opened and
  11642. + * passed to mkdir_p_at_internal(). */
  11643. + return glnx_throw_errno_prefix (error, "mkdir(%s)", path);
  11644. + }
  11645. +
  11646. + /* Note we can mutate the buffer as we dup'd it */
  11647. + *lastslash = '\0';
  11648. +
  11649. + if (!glnx_shutil_mkdir_p_at (dfd, path, mode,
  11650. + cancellable, error))
  11651. + return FALSE;
  11652. +
  11653. + /* Now restore it for another mkdir attempt */
  11654. + *lastslash = '/';
  11655. +
  11656. + did_recurse = TRUE;
  11657. + goto again;
  11658. + }
  11659. + else if (errno == EEXIST)
  11660. + {
  11661. + /* Fall through; it may not have been a directory,
  11662. + * but we'll find that out on the next call up.
  11663. + */
  11664. + }
  11665. + else
  11666. + return glnx_throw_errno_prefix (error, "mkdir(%s)", path);
  11667. + }
  11668. +
  11669. + return TRUE;
  11670. +}
  11671. +
  11672. +/**
  11673. + * glnx_shutil_mkdir_p_at:
  11674. + * @dfd: Directory fd
  11675. + * @path: Directory path to be created
  11676. + * @mode: Mode for newly created directories
  11677. + * @cancellable: Cancellable
  11678. + * @error: Error
  11679. + *
  11680. + * Similar to g_mkdir_with_parents(), except operates relative to the
  11681. + * directory fd @dfd.
  11682. + *
  11683. + * See also glnx_ensure_dir() for a non-recursive version.
  11684. + *
  11685. + * This will return %G_IO_ERROR_NOT_FOUND if @dfd has been deleted since being
  11686. + * opened. It may return other errors from mkdirat() in other situations.
  11687. + */
  11688. +gboolean
  11689. +glnx_shutil_mkdir_p_at (int dfd,
  11690. + const char *path,
  11691. + int mode,
  11692. + GCancellable *cancellable,
  11693. + GError **error)
  11694. +{
  11695. + struct stat stbuf;
  11696. + char *buf;
  11697. +
  11698. + /* Fast path stat to see whether it already exists */
  11699. + if (fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
  11700. + {
  11701. + /* Note early return */
  11702. + if (S_ISDIR (stbuf.st_mode))
  11703. + return TRUE;
  11704. + }
  11705. +
  11706. + buf = strdupa (path);
  11707. +
  11708. + if (!mkdir_p_at_internal (dfd, buf, mode, cancellable, error))
  11709. + return FALSE;
  11710. +
  11711. + return TRUE;
  11712. +}
  11713. +
  11714. +/**
  11715. + * glnx_shutil_mkdir_p_at_open:
  11716. + * @dfd: Directory fd
  11717. + * @path: Directory path to be created
  11718. + * @mode: Mode for newly created directories
  11719. + * @out_dfd: (out caller-allocates): Return location for an FD to @dfd/@path,
  11720. + * or `-1` on error
  11721. + * @cancellable: (nullable): Cancellable, or %NULL
  11722. + * @error: Return location for a #GError, or %NULL
  11723. + *
  11724. + * Similar to glnx_shutil_mkdir_p_at(), except it opens the resulting directory
  11725. + * and returns a directory FD to it. Currently, this is not guaranteed to be
  11726. + * race-free.
  11727. + *
  11728. + * Returns: %TRUE on success, %FALSE otherwise
  11729. + * Since: UNRELEASED
  11730. + */
  11731. +gboolean
  11732. +glnx_shutil_mkdir_p_at_open (int dfd,
  11733. + const char *path,
  11734. + int mode,
  11735. + int *out_dfd,
  11736. + GCancellable *cancellable,
  11737. + GError **error)
  11738. +{
  11739. + /* FIXME: It’s not possible to eliminate the race here until
  11740. + * openat(O_DIRECTORY | O_CREAT) works (and returns a directory rather than a
  11741. + * file). It appears to be not supported in current kernels. (Tested with
  11742. + * 4.10.10-200.fc25.x86_64.) */
  11743. + *out_dfd = -1;
  11744. +
  11745. + if (!glnx_shutil_mkdir_p_at (dfd, path, mode, cancellable, error))
  11746. + return FALSE;
  11747. +
  11748. + return glnx_opendirat (dfd, path, TRUE, out_dfd, error);
  11749. +}
  11750. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-shutil.h flatpak-1.0.0/libglnx/glnx-shutil.h
  11751. --- flatpak-1.0.0.orig/libglnx/glnx-shutil.h 1970-01-01 02:00:00.000000000 +0200
  11752. +++ flatpak-1.0.0/libglnx/glnx-shutil.h 2018-02-03 21:26:06.309233341 +0300
  11753. @@ -0,0 +1,48 @@
  11754. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  11755. + *
  11756. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  11757. + *
  11758. + * This library is free software; you can redistribute it and/or
  11759. + * modify it under the terms of the GNU Lesser General Public
  11760. + * License as published by the Free Software Foundation; either
  11761. + * version 2 of the License, or (at your option) any later version.
  11762. + *
  11763. + * This library is distributed in the hope that it will be useful,
  11764. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11765. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11766. + * Lesser General Public License for more details.
  11767. + *
  11768. + * You should have received a copy of the GNU Lesser General Public
  11769. + * License along with this library; if not, write to the
  11770. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  11771. + * Boston, MA 02111-1307, USA.
  11772. + */
  11773. +
  11774. +#pragma once
  11775. +
  11776. +#include <glnx-dirfd.h>
  11777. +
  11778. +G_BEGIN_DECLS
  11779. +
  11780. +gboolean
  11781. +glnx_shutil_rm_rf_at (int dfd,
  11782. + const char *path,
  11783. + GCancellable *cancellable,
  11784. + GError **error);
  11785. +
  11786. +gboolean
  11787. +glnx_shutil_mkdir_p_at (int dfd,
  11788. + const char *path,
  11789. + int mode,
  11790. + GCancellable *cancellable,
  11791. + GError **error);
  11792. +
  11793. +gboolean
  11794. +glnx_shutil_mkdir_p_at_open (int dfd,
  11795. + const char *path,
  11796. + int mode,
  11797. + int *out_dfd,
  11798. + GCancellable *cancellable,
  11799. + GError **error);
  11800. +
  11801. +G_END_DECLS
  11802. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-xattrs.c flatpak-1.0.0/libglnx/glnx-xattrs.c
  11803. --- flatpak-1.0.0.orig/libglnx/glnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
  11804. +++ flatpak-1.0.0/libglnx/glnx-xattrs.c 2018-02-03 21:26:06.309233341 +0300
  11805. @@ -0,0 +1,444 @@
  11806. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  11807. + *
  11808. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  11809. + *
  11810. + * This library is free software; you can redistribute it and/or
  11811. + * modify it under the terms of the GNU Lesser General Public
  11812. + * License as published by the Free Software Foundation; either
  11813. + * version 2 of the License, or (at your option) any later version.
  11814. + *
  11815. + * This library is distributed in the hope that it will be useful,
  11816. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11817. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11818. + * Lesser General Public License for more details.
  11819. + *
  11820. + * You should have received a copy of the GNU Lesser General Public
  11821. + * License along with this library; if not, write to the
  11822. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  11823. + * Boston, MA 02111-1307, USA.
  11824. + */
  11825. +
  11826. +#include "config.h"
  11827. +
  11828. +#include <string.h>
  11829. +#include <stdio.h>
  11830. +
  11831. +#include <glnx-macros.h>
  11832. +#include <glnx-xattrs.h>
  11833. +#include <glnx-errors.h>
  11834. +#include <glnx-local-alloc.h>
  11835. +
  11836. +static GVariant *
  11837. +variant_new_ay_bytes (GBytes *bytes)
  11838. +{
  11839. + gsize size;
  11840. + gconstpointer data;
  11841. + data = g_bytes_get_data (bytes, &size);
  11842. + g_bytes_ref (bytes);
  11843. + return g_variant_new_from_data (G_VARIANT_TYPE ("ay"), data, size,
  11844. + TRUE, (GDestroyNotify)g_bytes_unref, bytes);
  11845. +}
  11846. +
  11847. +static char *
  11848. +canonicalize_xattrs (char *xattr_string,
  11849. + size_t len)
  11850. +{
  11851. + char *p;
  11852. + GSList *xattrs = NULL;
  11853. + GSList *iter;
  11854. + GString *result;
  11855. +
  11856. + result = g_string_new (0);
  11857. +
  11858. + p = xattr_string;
  11859. + while (p < xattr_string+len)
  11860. + {
  11861. + xattrs = g_slist_prepend (xattrs, p);
  11862. + p += strlen (p) + 1;
  11863. + }
  11864. +
  11865. + xattrs = g_slist_sort (xattrs, (GCompareFunc) strcmp);
  11866. + for (iter = xattrs; iter; iter = iter->next) {
  11867. + g_string_append (result, iter->data);
  11868. + g_string_append_c (result, '\0');
  11869. + }
  11870. +
  11871. + g_slist_free (xattrs);
  11872. + return g_string_free (result, FALSE);
  11873. +}
  11874. +
  11875. +static gboolean
  11876. +read_xattr_name_array (const char *path,
  11877. + int fd,
  11878. + const char *xattrs,
  11879. + size_t len,
  11880. + GVariantBuilder *builder,
  11881. + GError **error)
  11882. +{
  11883. + gboolean ret = FALSE;
  11884. + const char *p;
  11885. + int r;
  11886. + const char *funcstr;
  11887. +
  11888. + g_assert (path != NULL || fd != -1);
  11889. +
  11890. + funcstr = fd != -1 ? "fgetxattr" : "lgetxattr";
  11891. +
  11892. + for (p = xattrs; p < xattrs+len; p = p + strlen (p) + 1)
  11893. + {
  11894. + ssize_t bytes_read;
  11895. + g_autofree char *buf = NULL;
  11896. + g_autoptr(GBytes) bytes = NULL;
  11897. +
  11898. + again:
  11899. + if (fd != -1)
  11900. + bytes_read = fgetxattr (fd, p, NULL, 0);
  11901. + else
  11902. + bytes_read = lgetxattr (path, p, NULL, 0);
  11903. + if (bytes_read < 0)
  11904. + {
  11905. + if (errno == ENODATA)
  11906. + continue;
  11907. +
  11908. + glnx_set_prefix_error_from_errno (error, "%s", funcstr);
  11909. + goto out;
  11910. + }
  11911. + if (bytes_read == 0)
  11912. + continue;
  11913. +
  11914. + buf = g_malloc (bytes_read);
  11915. + if (fd != -1)
  11916. + r = fgetxattr (fd, p, buf, bytes_read);
  11917. + else
  11918. + r = lgetxattr (path, p, buf, bytes_read);
  11919. + if (r < 0)
  11920. + {
  11921. + if (errno == ERANGE)
  11922. + {
  11923. + g_free (g_steal_pointer (&buf));
  11924. + goto again;
  11925. + }
  11926. + else if (errno == ENODATA)
  11927. + continue;
  11928. +
  11929. + glnx_set_prefix_error_from_errno (error, "%s", funcstr);
  11930. + goto out;
  11931. + }
  11932. +
  11933. + bytes = g_bytes_new_take (g_steal_pointer (&buf), bytes_read);
  11934. + g_variant_builder_add (builder, "(@ay@ay)",
  11935. + g_variant_new_bytestring (p),
  11936. + variant_new_ay_bytes (bytes));
  11937. + }
  11938. +
  11939. + ret = TRUE;
  11940. + out:
  11941. + return ret;
  11942. +}
  11943. +
  11944. +static gboolean
  11945. +get_xattrs_impl (const char *path,
  11946. + int fd,
  11947. + GVariant **out_xattrs,
  11948. + GCancellable *cancellable,
  11949. + GError **error)
  11950. +{
  11951. + gboolean ret = FALSE;
  11952. + ssize_t bytes_read, real_size;
  11953. + g_autofree char *xattr_names = NULL;
  11954. + g_autofree char *xattr_names_canonical = NULL;
  11955. + GVariantBuilder builder;
  11956. + gboolean builder_initialized = FALSE;
  11957. + g_autoptr(GVariant) ret_xattrs = NULL;
  11958. +
  11959. + g_assert (path != NULL || fd != -1);
  11960. +
  11961. + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ayay)"));
  11962. + builder_initialized = TRUE;
  11963. +
  11964. + again:
  11965. + if (path)
  11966. + bytes_read = llistxattr (path, NULL, 0);
  11967. + else
  11968. + bytes_read = flistxattr (fd, NULL, 0);
  11969. +
  11970. + if (bytes_read < 0)
  11971. + {
  11972. + if (errno != ENOTSUP)
  11973. + {
  11974. + glnx_set_prefix_error_from_errno (error, "%s", "llistxattr");
  11975. + goto out;
  11976. + }
  11977. + }
  11978. + else if (bytes_read > 0)
  11979. + {
  11980. + xattr_names = g_malloc (bytes_read);
  11981. + if (path)
  11982. + real_size = llistxattr (path, xattr_names, bytes_read);
  11983. + else
  11984. + real_size = flistxattr (fd, xattr_names, bytes_read);
  11985. + if (real_size < 0)
  11986. + {
  11987. + if (errno == ERANGE)
  11988. + {
  11989. + g_free (xattr_names);
  11990. + goto again;
  11991. + }
  11992. + glnx_set_prefix_error_from_errno (error, "%s", "llistxattr");
  11993. + goto out;
  11994. + }
  11995. + else if (real_size > 0)
  11996. + {
  11997. + xattr_names_canonical = canonicalize_xattrs (xattr_names, real_size);
  11998. +
  11999. + if (!read_xattr_name_array (path, fd, xattr_names_canonical, real_size, &builder, error))
  12000. + goto out;
  12001. + }
  12002. + }
  12003. +
  12004. + ret_xattrs = g_variant_builder_end (&builder);
  12005. + builder_initialized = FALSE;
  12006. + g_variant_ref_sink (ret_xattrs);
  12007. +
  12008. + ret = TRUE;
  12009. + if (out_xattrs)
  12010. + *out_xattrs = g_steal_pointer (&ret_xattrs);
  12011. + out:
  12012. + if (!builder_initialized)
  12013. + g_variant_builder_clear (&builder);
  12014. + return ret;
  12015. +}
  12016. +
  12017. +/**
  12018. + * glnx_fd_get_all_xattrs:
  12019. + * @fd: a file descriptor
  12020. + * @out_xattrs: (out): A new #GVariant containing the extended attributes
  12021. + * @cancellable: Cancellable
  12022. + * @error: Error
  12023. + *
  12024. + * Read all extended attributes from @fd in a canonical sorted order, and
  12025. + * set @out_xattrs with the result.
  12026. + *
  12027. + * If the filesystem does not support extended attributes, @out_xattrs
  12028. + * will have 0 elements, and this function will return successfully.
  12029. + */
  12030. +gboolean
  12031. +glnx_fd_get_all_xattrs (int fd,
  12032. + GVariant **out_xattrs,
  12033. + GCancellable *cancellable,
  12034. + GError **error)
  12035. +{
  12036. + return get_xattrs_impl (NULL, fd, out_xattrs,
  12037. + cancellable, error);
  12038. +}
  12039. +
  12040. +/**
  12041. + * glnx_dfd_name_get_all_xattrs:
  12042. + * @dfd: Parent directory file descriptor
  12043. + * @name: File name
  12044. + * @out_xattrs: (out): Extended attribute set
  12045. + * @cancellable: Cancellable
  12046. + * @error: Error
  12047. + *
  12048. + * Load all extended attributes for the file named @name residing in
  12049. + * directory @dfd.
  12050. + */
  12051. +gboolean
  12052. +glnx_dfd_name_get_all_xattrs (int dfd,
  12053. + const char *name,
  12054. + GVariant **out_xattrs,
  12055. + GCancellable *cancellable,
  12056. + GError **error)
  12057. +{
  12058. + if (G_IN_SET(dfd, AT_FDCWD, -1))
  12059. + {
  12060. + return get_xattrs_impl (name, -1, out_xattrs, cancellable, error);
  12061. + }
  12062. + else
  12063. + {
  12064. + char buf[PATH_MAX];
  12065. + /* A workaround for the lack of lgetxattrat(), thanks to Florian Weimer:
  12066. + * https://mail.gnome.org/archives/ostree-list/2014-February/msg00017.html
  12067. + */
  12068. + snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", dfd, name);
  12069. + return get_xattrs_impl (buf, -1, out_xattrs, cancellable, error);
  12070. + }
  12071. +}
  12072. +
  12073. +static gboolean
  12074. +set_all_xattrs_for_path (const char *path,
  12075. + GVariant *xattrs,
  12076. + GCancellable *cancellable,
  12077. + GError **error)
  12078. +{
  12079. + const guint n = g_variant_n_children (xattrs);
  12080. + for (guint i = 0; i < n; i++)
  12081. + {
  12082. + const guint8* name;
  12083. + g_autoptr(GVariant) value = NULL;
  12084. + g_variant_get_child (xattrs, i, "(^&ay@ay)",
  12085. + &name, &value);
  12086. +
  12087. + gsize value_len;
  12088. + const guint8* value_data = g_variant_get_fixed_array (value, &value_len, 1);
  12089. +
  12090. + if (lsetxattr (path, (char*)name, (char*)value_data, value_len, 0) < 0)
  12091. + return glnx_throw_errno_prefix (error, "lsetxattr");
  12092. + }
  12093. +
  12094. + return TRUE;
  12095. +}
  12096. +
  12097. +/**
  12098. + * glnx_dfd_name_set_all_xattrs:
  12099. + * @dfd: Parent directory file descriptor
  12100. + * @name: File name
  12101. + * @xattrs: Extended attribute set
  12102. + * @cancellable: Cancellable
  12103. + * @error: Error
  12104. + *
  12105. + * Set all extended attributes for the file named @name residing in
  12106. + * directory @dfd.
  12107. + */
  12108. +gboolean
  12109. +glnx_dfd_name_set_all_xattrs (int dfd,
  12110. + const char *name,
  12111. + GVariant *xattrs,
  12112. + GCancellable *cancellable,
  12113. + GError **error)
  12114. +{
  12115. + if (G_IN_SET(dfd, AT_FDCWD, -1))
  12116. + {
  12117. + return set_all_xattrs_for_path (name, xattrs, cancellable, error);
  12118. + }
  12119. + else
  12120. + {
  12121. + char buf[PATH_MAX];
  12122. + /* A workaround for the lack of lsetxattrat(), thanks to Florian Weimer:
  12123. + * https://mail.gnome.org/archives/ostree-list/2014-February/msg00017.html
  12124. + */
  12125. + snprintf (buf, sizeof (buf), "/proc/self/fd/%d/%s", dfd, name);
  12126. + return set_all_xattrs_for_path (buf, xattrs, cancellable, error);
  12127. + }
  12128. +}
  12129. +
  12130. +/**
  12131. + * glnx_fd_set_all_xattrs:
  12132. + * @fd: File descriptor
  12133. + * @xattrs: Extended attributes
  12134. + * @cancellable: Cancellable
  12135. + * @error: Error
  12136. + *
  12137. + * For each attribute in @xattrs, set its value on the file or
  12138. + * directory referred to by @fd. This function does not remove any
  12139. + * attributes not in @xattrs.
  12140. + */
  12141. +gboolean
  12142. +glnx_fd_set_all_xattrs (int fd,
  12143. + GVariant *xattrs,
  12144. + GCancellable *cancellable,
  12145. + GError **error)
  12146. +{
  12147. + const guint n = g_variant_n_children (xattrs);
  12148. + for (guint i = 0; i < n; i++)
  12149. + {
  12150. + const guint8* name;
  12151. + g_autoptr(GVariant) value = NULL;
  12152. + g_variant_get_child (xattrs, i, "(^&ay@ay)",
  12153. + &name, &value);
  12154. +
  12155. + gsize value_len;
  12156. + const guint8* value_data = g_variant_get_fixed_array (value, &value_len, 1);
  12157. +
  12158. + if (TEMP_FAILURE_RETRY (fsetxattr (fd, (char*)name, (char*)value_data, value_len, 0)) < 0)
  12159. + return glnx_throw_errno_prefix (error, "fsetxattr");
  12160. + }
  12161. +
  12162. + return TRUE;
  12163. +}
  12164. +
  12165. +/**
  12166. + * glnx_lgetxattrat:
  12167. + * @dfd: Directory file descriptor
  12168. + * @subpath: Subpath
  12169. + * @attribute: Extended attribute to retrieve
  12170. + * @error: Error
  12171. + *
  12172. + * Retrieve an extended attribute value, relative to a directory file
  12173. + * descriptor.
  12174. + */
  12175. +GBytes *
  12176. +glnx_lgetxattrat (int dfd,
  12177. + const char *subpath,
  12178. + const char *attribute,
  12179. + GError **error)
  12180. +{
  12181. + char pathbuf[PATH_MAX];
  12182. + snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath);
  12183. +
  12184. + ssize_t bytes_read, real_size;
  12185. + if (TEMP_FAILURE_RETRY (bytes_read = lgetxattr (pathbuf, attribute, NULL, 0)) < 0)
  12186. + return glnx_null_throw_errno_prefix (error, "lgetxattr");
  12187. +
  12188. + g_autofree guint8 *buf = g_malloc (bytes_read);
  12189. + if (TEMP_FAILURE_RETRY (real_size = lgetxattr (pathbuf, attribute, buf, bytes_read)) < 0)
  12190. + return glnx_null_throw_errno_prefix (error, "lgetxattr");
  12191. +
  12192. + return g_bytes_new_take (g_steal_pointer (&buf), real_size);
  12193. +}
  12194. +
  12195. +/**
  12196. + * glnx_fgetxattr_bytes:
  12197. + * @fd: Directory file descriptor
  12198. + * @attribute: Extended attribute to retrieve
  12199. + * @error: Error
  12200. + *
  12201. + * Returns: (transfer full): An extended attribute value, or %NULL on error
  12202. + */
  12203. +GBytes *
  12204. +glnx_fgetxattr_bytes (int fd,
  12205. + const char *attribute,
  12206. + GError **error)
  12207. +{
  12208. + ssize_t bytes_read, real_size;
  12209. +
  12210. + if (TEMP_FAILURE_RETRY (bytes_read = fgetxattr (fd, attribute, NULL, 0)) < 0)
  12211. + return glnx_null_throw_errno_prefix (error, "fgetxattr");
  12212. +
  12213. + g_autofree guint8 *buf = g_malloc (bytes_read);
  12214. + if (TEMP_FAILURE_RETRY (real_size = fgetxattr (fd, attribute, buf, bytes_read)) < 0)
  12215. + return glnx_null_throw_errno_prefix (error, "fgetxattr");
  12216. +
  12217. + return g_bytes_new_take (g_steal_pointer (&buf), real_size);
  12218. +}
  12219. +
  12220. +/**
  12221. + * glnx_lsetxattrat:
  12222. + * @dfd: Directory file descriptor
  12223. + * @subpath: Path
  12224. + * @attribute: An attribute name
  12225. + * @value: (array length=len) (element-type guint8): Attribute value
  12226. + * @len: Length of @value
  12227. + * @flags: Flags, containing either XATTR_CREATE or XATTR_REPLACE
  12228. + * @error: Error
  12229. + *
  12230. + * Set an extended attribute, relative to a directory file descriptor.
  12231. + */
  12232. +gboolean
  12233. +glnx_lsetxattrat (int dfd,
  12234. + const char *subpath,
  12235. + const char *attribute,
  12236. + const guint8 *value,
  12237. + gsize len,
  12238. + int flags,
  12239. + GError **error)
  12240. +{
  12241. + char pathbuf[PATH_MAX];
  12242. + snprintf (pathbuf, sizeof (pathbuf), "/proc/self/fd/%d/%s", dfd, subpath);
  12243. +
  12244. + if (TEMP_FAILURE_RETRY (lsetxattr (subpath, attribute, value, len, flags)) < 0)
  12245. + return glnx_throw_errno_prefix (error, "lsetxattr");
  12246. +
  12247. + return TRUE;
  12248. +}
  12249. +
  12250. diff -Nuar flatpak-1.0.0.orig/libglnx/glnx-xattrs.h flatpak-1.0.0/libglnx/glnx-xattrs.h
  12251. --- flatpak-1.0.0.orig/libglnx/glnx-xattrs.h 1970-01-01 02:00:00.000000000 +0200
  12252. +++ flatpak-1.0.0/libglnx/glnx-xattrs.h 2018-02-03 21:26:06.309233341 +0300
  12253. @@ -0,0 +1,78 @@
  12254. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  12255. + *
  12256. + * Copyright (C) 2014,2015 Colin Walters <walters@verbum.org>.
  12257. + *
  12258. + * This library is free software; you can redistribute it and/or
  12259. + * modify it under the terms of the GNU Lesser General Public
  12260. + * License as published by the Free Software Foundation; either
  12261. + * version 2 of the License, or (at your option) any later version.
  12262. + *
  12263. + * This library is distributed in the hope that it will be useful,
  12264. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12265. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12266. + * Lesser General Public License for more details.
  12267. + *
  12268. + * You should have received a copy of the GNU Lesser General Public
  12269. + * License along with this library; if not, write to the
  12270. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12271. + * Boston, MA 02111-1307, USA.
  12272. + */
  12273. +
  12274. +#pragma once
  12275. +
  12276. +#include <glnx-backport-autocleanups.h>
  12277. +#include <limits.h>
  12278. +#include <dirent.h>
  12279. +#include <sys/stat.h>
  12280. +#include <fcntl.h>
  12281. +#include <sys/xattr.h>
  12282. +
  12283. +G_BEGIN_DECLS
  12284. +
  12285. +gboolean
  12286. +glnx_dfd_name_get_all_xattrs (int dfd,
  12287. + const char *name,
  12288. + GVariant **out_xattrs,
  12289. + GCancellable *cancellable,
  12290. + GError **error);
  12291. +
  12292. +gboolean
  12293. +glnx_fd_get_all_xattrs (int fd,
  12294. + GVariant **out_xattrs,
  12295. + GCancellable *cancellable,
  12296. + GError **error);
  12297. +
  12298. +gboolean
  12299. +glnx_dfd_name_set_all_xattrs (int dfd,
  12300. + const char *name,
  12301. + GVariant *xattrs,
  12302. + GCancellable *cancellable,
  12303. + GError **error);
  12304. +
  12305. +gboolean
  12306. +glnx_fd_set_all_xattrs (int fd,
  12307. + GVariant *xattrs,
  12308. + GCancellable *cancellable,
  12309. + GError **error);
  12310. +
  12311. +GBytes *
  12312. +glnx_lgetxattrat (int dfd,
  12313. + const char *subpath,
  12314. + const char *attribute,
  12315. + GError **error);
  12316. +
  12317. +GBytes *
  12318. +glnx_fgetxattr_bytes (int fd,
  12319. + const char *attribute,
  12320. + GError **error);
  12321. +
  12322. +gboolean
  12323. +glnx_lsetxattrat (int dfd,
  12324. + const char *subpath,
  12325. + const char *attribute,
  12326. + const guint8 *value,
  12327. + gsize len,
  12328. + int flags,
  12329. + GError **error);
  12330. +
  12331. +G_END_DECLS
  12332. diff -Nuar flatpak-1.0.0.orig/libglnx/libglnx.doap flatpak-1.0.0/libglnx/libglnx.doap
  12333. --- flatpak-1.0.0.orig/libglnx/libglnx.doap 1970-01-01 02:00:00.000000000 +0200
  12334. +++ flatpak-1.0.0/libglnx/libglnx.doap 2018-02-03 21:26:06.309233341 +0300
  12335. @@ -0,0 +1,31 @@
  12336. +<?xml version="1.0" encoding="UTF-8"?>
  12337. +<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  12338. + xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  12339. + xmlns:foaf="http://xmlns.com/foaf/0.1/"
  12340. + xmlns:gnome="http://api.gnome.org/doap-extensions#"
  12341. + xmlns="http://usefulinc.com/ns/doap#">
  12342. +
  12343. + <name>libglnx</name>
  12344. + <shortname>libglnx</shortname>
  12345. +
  12346. + <shortdesc xml:lang="en">"Copylib" for system service modules using GLib with Linux</shortdesc>
  12347. +
  12348. + <description xml:lang="en">This module is intended for use by
  12349. + infrastructure code using GLib that is also Linux specific, such as
  12350. + ostree, NetworkManager, and others.
  12351. + </description>
  12352. +
  12353. + <license rdf:resource="http://usefulinc.com/doap/licenses/lgpl" />
  12354. + <mailing-list rdf:resource="mailto:desktop-devel-list@gnome.org" />
  12355. +
  12356. + <programming-language>C</programming-language>
  12357. +
  12358. + <maintainer>
  12359. + <foaf:Person>
  12360. + <foaf:name>Colin Walters</foaf:name>
  12361. + <foaf:mbox rdf:resource="mailto:walters@verbum.org"/>
  12362. + <gnome:userid>walters</gnome:userid>
  12363. + </foaf:Person>
  12364. + </maintainer>
  12365. +
  12366. +</Project>
  12367. diff -Nuar flatpak-1.0.0.orig/libglnx/libglnx.h flatpak-1.0.0/libglnx/libglnx.h
  12368. --- flatpak-1.0.0.orig/libglnx/libglnx.h 1970-01-01 02:00:00.000000000 +0200
  12369. +++ flatpak-1.0.0/libglnx/libglnx.h 2018-02-03 21:26:06.309233341 +0300
  12370. @@ -0,0 +1,40 @@
  12371. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  12372. + *
  12373. + * Copyright (C) 2012,2013,2015 Colin Walters <walters@verbum.org>.
  12374. + *
  12375. + * This library is free software; you can redistribute it and/or
  12376. + * modify it under the terms of the GNU Lesser General Public
  12377. + * License as published by the Free Software Foundation; either
  12378. + * version 2 of the License, or (at your option) any later version.
  12379. + *
  12380. + * This library is distributed in the hope that it will be useful,
  12381. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12382. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12383. + * Lesser General Public License for more details.
  12384. + *
  12385. + * You should have received a copy of the GNU Lesser General Public
  12386. + * License along with this library; if not, write to the
  12387. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12388. + * Boston, MA 02111-1307, USA.
  12389. + */
  12390. +
  12391. +#pragma once
  12392. +
  12393. +#include <gio/gio.h>
  12394. +
  12395. +G_BEGIN_DECLS
  12396. +
  12397. +#include <glnx-macros.h>
  12398. +#include <glnx-missing.h>
  12399. +#include <glnx-local-alloc.h>
  12400. +#include <glnx-backport-autocleanups.h>
  12401. +#include <glnx-backports.h>
  12402. +#include <glnx-lockfile.h>
  12403. +#include <glnx-errors.h>
  12404. +#include <glnx-dirfd.h>
  12405. +#include <glnx-shutil.h>
  12406. +#include <glnx-xattrs.h>
  12407. +#include <glnx-console.h>
  12408. +#include <glnx-fdio.h>
  12409. +
  12410. +G_END_DECLS
  12411. diff -Nuar flatpak-1.0.0.orig/libglnx/libglnx.m4 flatpak-1.0.0/libglnx/libglnx.m4
  12412. --- flatpak-1.0.0.orig/libglnx/libglnx.m4 1970-01-01 02:00:00.000000000 +0200
  12413. +++ flatpak-1.0.0/libglnx/libglnx.m4 2018-05-26 00:50:25.434037228 +0300
  12414. @@ -0,0 +1,33 @@
  12415. +AC_DEFUN([LIBGLNX_CONFIGURE],
  12416. +[
  12417. +AC_CHECK_DECLS([
  12418. + renameat2,
  12419. + memfd_create,
  12420. + copy_file_range],
  12421. + [], [], [[
  12422. +#include <sys/types.h>
  12423. +#include <unistd.h>
  12424. +#include <sys/mount.h>
  12425. +#include <fcntl.h>
  12426. +#include <sched.h>
  12427. +#include <linux/loop.h>
  12428. +#include <linux/random.h>
  12429. +#include <sys/mman.h>
  12430. +]])
  12431. +
  12432. +AC_ARG_ENABLE(otmpfile,
  12433. + [AS_HELP_STRING([--disable-otmpfile],
  12434. + [Disable use of O_TMPFILE [default=no]])],,
  12435. + [enable_otmpfile=yes])
  12436. +AS_IF([test $enable_otmpfile = yes], [], [
  12437. + AC_DEFINE([DISABLE_OTMPFILE], 1, [Define if we should avoid using O_TMPFILE])])
  12438. +
  12439. +AC_ARG_ENABLE(wrpseudo-compat,
  12440. + [AS_HELP_STRING([--enable-wrpseudo-compat],
  12441. + [Disable use syscall() and filesystem calls to for compatibility with wrpseudo [default=no]])],,
  12442. + [enable_wrpseudo_compat=no])
  12443. +AS_IF([test $enable_wrpseudo_compat = no], [], [
  12444. + AC_DEFINE([ENABLE_WRPSEUDO_COMPAT], 1, [Define if we should be compatible with wrpseudo])])
  12445. +
  12446. +dnl end LIBGLNX_CONFIGURE
  12447. +])
  12448. diff -Nuar flatpak-1.0.0.orig/libglnx/Makefile-libglnx.am flatpak-1.0.0/libglnx/Makefile-libglnx.am
  12449. --- flatpak-1.0.0.orig/libglnx/Makefile-libglnx.am 1970-01-01 02:00:00.000000000 +0200
  12450. +++ flatpak-1.0.0/libglnx/Makefile-libglnx.am 2018-02-03 21:26:06.307233341 +0300
  12451. @@ -0,0 +1,78 @@
  12452. +# Copyright (C) 2015 Colin Walters <walters@verbum.org>
  12453. +#
  12454. +# This library is free software; you can redistribute it and/or
  12455. +# modify it under the terms of the GNU Lesser General Public
  12456. +# License as published by the Free Software Foundation; either
  12457. +# version 2 of the License, or (at your option) any later version.
  12458. +#
  12459. +# This library is distributed in the hope that it will be useful,
  12460. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12461. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12462. +# Lesser General Public License for more details.
  12463. +#
  12464. +# You should have received a copy of the GNU Lesser General Public
  12465. +# License along with this library; if not, write to the
  12466. +# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12467. +# Boston, MA 02111-1307, USA.
  12468. +
  12469. +EXTRA_DIST += \
  12470. + $(libglnx_srcpath)/README.md \
  12471. + $(libglnx_srcpath)/COPYING \
  12472. + $(libglnx_srcpath)/libglnx.m4 \
  12473. + $(NULL)
  12474. +
  12475. +libglnx_la_SOURCES = \
  12476. + $(libglnx_srcpath)/glnx-macros.h \
  12477. + $(libglnx_srcpath)/glnx-backport-autocleanups.h \
  12478. + $(libglnx_srcpath)/glnx-backport-autoptr.h \
  12479. + $(libglnx_srcpath)/glnx-backports.h \
  12480. + $(libglnx_srcpath)/glnx-backports.c \
  12481. + $(libglnx_srcpath)/glnx-local-alloc.h \
  12482. + $(libglnx_srcpath)/glnx-local-alloc.c \
  12483. + $(libglnx_srcpath)/glnx-errors.h \
  12484. + $(libglnx_srcpath)/glnx-errors.c \
  12485. + $(libglnx_srcpath)/glnx-console.h \
  12486. + $(libglnx_srcpath)/glnx-console.c \
  12487. + $(libglnx_srcpath)/glnx-dirfd.h \
  12488. + $(libglnx_srcpath)/glnx-dirfd.c \
  12489. + $(libglnx_srcpath)/glnx-fdio.h \
  12490. + $(libglnx_srcpath)/glnx-fdio.c \
  12491. + $(libglnx_srcpath)/glnx-lockfile.h \
  12492. + $(libglnx_srcpath)/glnx-lockfile.c \
  12493. + $(libglnx_srcpath)/glnx-missing-syscall.h \
  12494. + $(libglnx_srcpath)/glnx-missing.h \
  12495. + $(libglnx_srcpath)/glnx-xattrs.h \
  12496. + $(libglnx_srcpath)/glnx-xattrs.c \
  12497. + $(libglnx_srcpath)/glnx-shutil.h \
  12498. + $(libglnx_srcpath)/glnx-shutil.c \
  12499. + $(libglnx_srcpath)/libglnx.h \
  12500. + $(libglnx_srcpath)/tests/libglnx-testlib.h \
  12501. + $(NULL)
  12502. +
  12503. +libglnx_la_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12504. +libglnx_la_LDFLAGS = -avoid-version -Bsymbolic-functions -export-symbols-regex "^glnx_" -no-undefined -export-dynamic
  12505. +libglnx_la_LIBADD = $(libglnx_libs)
  12506. +
  12507. +libglnx_tests = test-libglnx-xattrs test-libglnx-fdio test-libglnx-errors test-libglnx-macros test-libglnx-shutil
  12508. +TESTS += $(libglnx_tests)
  12509. +
  12510. +check_PROGRAMS += $(libglnx_tests)
  12511. +test_libglnx_xattrs_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-xattrs.c
  12512. +test_libglnx_xattrs_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12513. +test_libglnx_xattrs_LDADD = $(libglnx_libs) libglnx.la
  12514. +
  12515. +test_libglnx_fdio_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-fdio.c
  12516. +test_libglnx_fdio_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12517. +test_libglnx_fdio_LDADD = $(libglnx_libs) libglnx.la
  12518. +
  12519. +test_libglnx_errors_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-errors.c
  12520. +test_libglnx_errors_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12521. +test_libglnx_errors_LDADD = $(libglnx_libs) libglnx.la
  12522. +
  12523. +test_libglnx_macros_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-macros.c
  12524. +test_libglnx_macros_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12525. +test_libglnx_macros_LDADD = $(libglnx_libs) libglnx.la
  12526. +
  12527. +test_libglnx_shutil_SOURCES = $(libglnx_srcpath)/tests/test-libglnx-shutil.c
  12528. +test_libglnx_shutil_CFLAGS = $(AM_CFLAGS) $(libglnx_cflags)
  12529. +test_libglnx_shutil_LDADD = $(libglnx_libs) libglnx.la
  12530. diff -Nuar flatpak-1.0.0.orig/libglnx/README.md flatpak-1.0.0/libglnx/README.md
  12531. --- flatpak-1.0.0.orig/libglnx/README.md 1970-01-01 02:00:00.000000000 +0200
  12532. +++ flatpak-1.0.0/libglnx/README.md 2018-05-26 00:50:25.433037228 +0300
  12533. @@ -0,0 +1,52 @@
  12534. +libglnx is the successor to libgsystem: https://git.gnome.org/browse/libgsystem
  12535. +
  12536. +It is for modules which depend on both GLib and Linux, intended to be
  12537. +used as a git submodule.
  12538. +
  12539. +Features:
  12540. +
  12541. + - File APIs which use `openat()` like APIs, but also take a `GCancellable`
  12542. + to support dynamic cancellation
  12543. + - APIs also have a `GError` parameter
  12544. + - High level "shutil", somewhat inspired by Python's
  12545. + - A "console" API for tty output
  12546. + - A backport of the GLib cleanup macros for projects which can't yet take
  12547. + a dependency on 2.40.
  12548. +
  12549. +Why?
  12550. +----
  12551. +
  12552. +There are multiple projects which have a hard dependency on Linux and
  12553. +GLib, such as NetworkManager, ostree, flatpak, etc. It makes sense
  12554. +for them to be able to share Linux-specific APIs.
  12555. +
  12556. +This module also contains some code taken from systemd, which has very
  12557. +high quality LGPLv2+ shared library code, but most of the internal
  12558. +shared library is private, and not namespaced.
  12559. +
  12560. +One could also compare this project to gnulib; the salient differences
  12561. +there are that at least some of this module is eventually destined for
  12562. +inclusion in GLib.
  12563. +
  12564. +Porting from libgsystem
  12565. +-----------------------
  12566. +
  12567. +For all of the filesystem access code, libglnx exposes only
  12568. +fd-relative API, not `GFile*`. It does use `GCancellable` where
  12569. +applicable.
  12570. +
  12571. +For local allocation macros, you should start using the `g_auto`
  12572. +macros from GLib. A backport is included in libglnx. There are a few
  12573. +APIs not defined in GLib yet, such as `glnx_autofd`.
  12574. +
  12575. +`gs_transfer_out_value` is replaced by `g_steal_pointer`.
  12576. +
  12577. +Contributing
  12578. +------------
  12579. +
  12580. +Currently there is not a Bugzilla product - one may be created
  12581. +in the future. You can submit PRs against the Github mirror:
  12582. +
  12583. +https://github.com/GNOME/libglnx/pulls
  12584. +
  12585. +Or alternatively, email one of the maintainers directly.
  12586. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/libglnx-testlib.h flatpak-1.0.0/libglnx/tests/libglnx-testlib.h
  12587. --- flatpak-1.0.0.orig/libglnx/tests/libglnx-testlib.h 1970-01-01 02:00:00.000000000 +0200
  12588. +++ flatpak-1.0.0/libglnx/tests/libglnx-testlib.h 2018-02-03 21:26:06.309233341 +0300
  12589. @@ -0,0 +1,34 @@
  12590. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  12591. + *
  12592. + * Copyright (C) 2017 Red Hat, Inc.
  12593. + *
  12594. + * This library is free software; you can redistribute it and/or
  12595. + * modify it under the terms of the GNU Lesser General Public
  12596. + * License as published by the Free Software Foundation; either
  12597. + * version 2 of the License, or (at your option) any later version.
  12598. + *
  12599. + * This library is distributed in the hope that it will be useful,
  12600. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12601. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12602. + * Lesser General Public License for more details.
  12603. + *
  12604. + * You should have received a copy of the GNU Lesser General Public
  12605. + * License along with this library; if not, write to the
  12606. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12607. + * Boston, MA 02111-1307, USA.
  12608. + */
  12609. +
  12610. +#pragma once
  12611. +
  12612. +typedef GError _GLnxTestAutoError;
  12613. +static inline void
  12614. +_glnx_test_auto_error_cleanup (_GLnxTestAutoError *autoerror)
  12615. +{
  12616. + g_assert_no_error (autoerror);
  12617. + /* We could add a clear call here, but no point...we'll have aborted */
  12618. +}
  12619. +G_DEFINE_AUTOPTR_CLEANUP_FUNC(_GLnxTestAutoError, _glnx_test_auto_error_cleanup);
  12620. +
  12621. +#define _GLNX_TEST_DECLARE_ERROR(local_error, error) \
  12622. + g_autoptr(_GLnxTestAutoError) local_error = NULL; \
  12623. + GError **error = &local_error
  12624. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/test-libglnx-errors.c flatpak-1.0.0/libglnx/tests/test-libglnx-errors.c
  12625. --- flatpak-1.0.0.orig/libglnx/tests/test-libglnx-errors.c 1970-01-01 02:00:00.000000000 +0200
  12626. +++ flatpak-1.0.0/libglnx/tests/test-libglnx-errors.c 2018-02-03 21:26:06.309233341 +0300
  12627. @@ -0,0 +1,183 @@
  12628. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  12629. + *
  12630. + * Copyright (C) 2017 Red Hat, Inc.
  12631. + *
  12632. + * This library is free software; you can redistribute it and/or
  12633. + * modify it under the terms of the GNU Lesser General Public
  12634. + * License as published by the Free Software Foundation; either
  12635. + * version 2 of the License, or (at your option) any later version.
  12636. + *
  12637. + * This library is distributed in the hope that it will be useful,
  12638. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12639. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12640. + * Lesser General Public License for more details.
  12641. + *
  12642. + * You should have received a copy of the GNU Lesser General Public
  12643. + * License along with this library; if not, write to the
  12644. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12645. + * Boston, MA 02111-1307, USA.
  12646. + */
  12647. +
  12648. +#include "config.h"
  12649. +#include "libglnx.h"
  12650. +#include <glib.h>
  12651. +#include <stdlib.h>
  12652. +#include <gio/gio.h>
  12653. +#include <string.h>
  12654. +
  12655. +static void
  12656. +test_error_throw (void)
  12657. +{
  12658. + g_autoptr(GError) error = NULL;
  12659. +
  12660. + g_assert (!glnx_throw (&error, "foo: %s %d", "hello", 42));
  12661. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
  12662. + g_assert_cmpstr (error->message, ==, "foo: hello 42");
  12663. + g_clear_error (&error);
  12664. +
  12665. + gpointer dummy = glnx_null_throw (&error, "literal foo");
  12666. + g_assert (dummy == NULL);
  12667. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
  12668. + g_assert_cmpstr (error->message, ==, "literal foo");
  12669. + g_clear_error (&error);
  12670. +
  12671. + gpointer dummy2 = glnx_null_throw (&error, "foo: %s %d", "hola", 24);
  12672. + g_assert (dummy2 == NULL);
  12673. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_FAILED);
  12674. + g_assert_cmpstr (error->message, ==, "foo: hola 24");
  12675. + g_clear_error (&error);
  12676. +}
  12677. +
  12678. +static void
  12679. +test_error_errno (void)
  12680. +{
  12681. + g_autoptr(GError) error = NULL;
  12682. + const char noent_path[] = "/enoent-this-should-not-exist";
  12683. + int fd;
  12684. +
  12685. + fd = open (noent_path, O_RDONLY);
  12686. + if (fd < 0)
  12687. + {
  12688. + g_assert (!glnx_throw_errno (&error));
  12689. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12690. + g_assert (!glnx_prefix_error (&error, "myprefix"));
  12691. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12692. + g_assert (g_str_has_prefix (error->message, "myprefix: "));
  12693. + g_clear_error (&error);
  12694. + }
  12695. + else
  12696. + g_assert_cmpint (fd, ==, -1);
  12697. +
  12698. + fd = open (noent_path, O_RDONLY);
  12699. + if (fd < 0)
  12700. + {
  12701. + gpointer dummy = glnx_null_throw_errno (&error);
  12702. + g_assert (dummy == NULL);
  12703. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12704. + dummy = glnx_prefix_error_null (&error, "myprefix");
  12705. + g_assert (dummy == NULL);
  12706. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12707. + g_assert (g_str_has_prefix (error->message, "myprefix: "));
  12708. + g_clear_error (&error);
  12709. + }
  12710. + else
  12711. + g_assert_cmpint (fd, ==, -1);
  12712. +
  12713. + fd = open (noent_path, O_RDONLY);
  12714. + if (fd < 0)
  12715. + {
  12716. + g_autofree char *expected_prefix = g_strdup_printf ("Failed to open %s", noent_path);
  12717. + g_assert (!glnx_throw_errno_prefix (&error, "Failed to open %s", noent_path));
  12718. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12719. + g_assert (g_str_has_prefix (error->message, expected_prefix));
  12720. + g_clear_error (&error);
  12721. + /* And test the legacy wrapper */
  12722. + glnx_set_prefix_error_from_errno (&error, "Failed to open %s", noent_path);
  12723. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12724. + g_assert (g_str_has_prefix (error->message, expected_prefix));
  12725. + g_clear_error (&error);
  12726. + }
  12727. + else
  12728. + g_assert_cmpint (fd, ==, -1);
  12729. +
  12730. + fd = open (noent_path, O_RDONLY);
  12731. + if (fd < 0)
  12732. + {
  12733. + gpointer dummy = glnx_null_throw_errno_prefix (&error, "Failed to open file");
  12734. + g_assert (dummy == NULL);
  12735. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12736. + g_assert (g_str_has_prefix (error->message, "Failed to open file"));
  12737. + g_clear_error (&error);
  12738. + }
  12739. + else
  12740. + g_assert_cmpint (fd, ==, -1);
  12741. +
  12742. + fd = open (noent_path, O_RDONLY);
  12743. + if (fd < 0)
  12744. + {
  12745. + gpointer dummy = glnx_null_throw_errno_prefix (&error, "Failed to open %s", noent_path);
  12746. + g_assert (dummy == NULL);
  12747. + g_assert_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  12748. + g_assert (g_str_has_prefix (error->message, glnx_strjoina ("Failed to open ", noent_path)));
  12749. + g_clear_error (&error);
  12750. + }
  12751. + else
  12752. + g_assert_cmpint (fd, ==, -1);
  12753. +}
  12754. +
  12755. +static void
  12756. +test_error_auto_nothrow (GError **error)
  12757. +{
  12758. + GLNX_AUTO_PREFIX_ERROR("foo", error);
  12759. + /* Side effect to avoid otherwise empty function */
  12760. + g_assert_no_error (*error);
  12761. +}
  12762. +
  12763. +static void
  12764. +test_error_auto_throw (GError **error)
  12765. +{
  12766. + GLNX_AUTO_PREFIX_ERROR("foo", error);
  12767. + (void) glnx_throw (error, "oops");
  12768. +}
  12769. +
  12770. +static void
  12771. +test_error_auto_throw_recurse (GError **error)
  12772. +{
  12773. + GLNX_AUTO_PREFIX_ERROR("foo", error);
  12774. +
  12775. + if (TRUE)
  12776. + {
  12777. + GLNX_AUTO_PREFIX_ERROR("bar", error);
  12778. + (void) glnx_throw (error, "oops");
  12779. + }
  12780. +}
  12781. +
  12782. +static void
  12783. +test_error_auto (void)
  12784. +{
  12785. + g_autoptr(GError) error = NULL;
  12786. + test_error_auto_nothrow (&error);
  12787. + g_assert_no_error (error);
  12788. + test_error_auto_throw (&error);
  12789. + g_assert_nonnull (error);
  12790. + g_assert_cmpstr (error->message, ==, "foo: oops");
  12791. + g_clear_error (&error);
  12792. + test_error_auto_throw_recurse (&error);
  12793. + g_assert_nonnull (error);
  12794. + g_assert_cmpstr (error->message, ==, "foo: bar: oops");
  12795. +}
  12796. +
  12797. +int main (int argc, char **argv)
  12798. +{
  12799. + int ret;
  12800. +
  12801. + g_test_init (&argc, &argv, NULL);
  12802. +
  12803. + g_test_add_func ("/error-throw", test_error_throw);
  12804. + g_test_add_func ("/error-errno", test_error_errno);
  12805. + g_test_add_func ("/error-auto", test_error_auto);
  12806. +
  12807. + ret = g_test_run();
  12808. +
  12809. + return ret;
  12810. +}
  12811. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/test-libglnx-fdio.c flatpak-1.0.0/libglnx/tests/test-libglnx-fdio.c
  12812. --- flatpak-1.0.0.orig/libglnx/tests/test-libglnx-fdio.c 1970-01-01 02:00:00.000000000 +0200
  12813. +++ flatpak-1.0.0/libglnx/tests/test-libglnx-fdio.c 2018-05-26 00:50:25.435037228 +0300
  12814. @@ -0,0 +1,254 @@
  12815. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  12816. + *
  12817. + * Copyright (C) 2017 Red Hat, Inc.
  12818. + *
  12819. + * This library is free software; you can redistribute it and/or
  12820. + * modify it under the terms of the GNU Lesser General Public
  12821. + * License as published by the Free Software Foundation; either
  12822. + * version 2 of the License, or (at your option) any later version.
  12823. + *
  12824. + * This library is distributed in the hope that it will be useful,
  12825. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12826. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12827. + * Lesser General Public License for more details.
  12828. + *
  12829. + * You should have received a copy of the GNU Lesser General Public
  12830. + * License along with this library; if not, write to the
  12831. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  12832. + * Boston, MA 02111-1307, USA.
  12833. + */
  12834. +
  12835. +#include "config.h"
  12836. +#include "libglnx.h"
  12837. +#include <glib.h>
  12838. +#include <stdlib.h>
  12839. +#include <gio/gio.h>
  12840. +#include <err.h>
  12841. +#include <string.h>
  12842. +
  12843. +#include "libglnx-testlib.h"
  12844. +
  12845. +static gboolean
  12846. +renameat_test_setup (int *out_srcfd, int *out_destfd,
  12847. + GError **error)
  12848. +{
  12849. + glnx_autofd int srcfd = -1;
  12850. + glnx_autofd int destfd = -1;
  12851. +
  12852. + (void) glnx_shutil_rm_rf_at (AT_FDCWD, "srcdir", NULL, NULL);
  12853. + if (mkdir ("srcdir", 0755) < 0)
  12854. + err (1, "mkdir");
  12855. + if (!glnx_opendirat (AT_FDCWD, "srcdir", TRUE, &srcfd, error))
  12856. + return FALSE;
  12857. + (void) glnx_shutil_rm_rf_at (AT_FDCWD, "destdir", NULL, NULL);
  12858. + if (mkdir ("destdir", 0755) < 0)
  12859. + err (1, "mkdir");
  12860. + if (!glnx_opendirat (AT_FDCWD, "destdir", TRUE, &destfd, error))
  12861. + return FALSE;
  12862. +
  12863. + if (!glnx_file_replace_contents_at (srcfd, "foo", (guint8*)"foo contents", strlen ("foo contents"),
  12864. + GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
  12865. + return FALSE;
  12866. + if (!glnx_file_replace_contents_at (destfd, "bar", (guint8*)"bar contents", strlen ("bar contents"),
  12867. + GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
  12868. + return FALSE;
  12869. +
  12870. + *out_srcfd = srcfd; srcfd = -1;
  12871. + *out_destfd = destfd; destfd = -1;
  12872. + return TRUE;
  12873. +}
  12874. +
  12875. +static void
  12876. +test_renameat2_noreplace (void)
  12877. +{
  12878. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12879. + glnx_autofd int srcfd = -1;
  12880. + glnx_autofd int destfd = -1;
  12881. + struct stat stbuf;
  12882. +
  12883. + if (!renameat_test_setup (&srcfd, &destfd, error))
  12884. + return;
  12885. +
  12886. + if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "bar") == 0)
  12887. + g_assert_not_reached ();
  12888. + else
  12889. + {
  12890. + g_assert_cmpint (errno, ==, EEXIST);
  12891. + }
  12892. +
  12893. + if (glnx_renameat2_noreplace (srcfd, "foo", destfd, "baz") < 0)
  12894. + return (void)glnx_throw_errno_prefix (error, "renameat");
  12895. + if (!glnx_fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  12896. + return;
  12897. +
  12898. + if (fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW) == 0)
  12899. + g_assert_not_reached ();
  12900. + else
  12901. + g_assert_cmpint (errno, ==, ENOENT);
  12902. +}
  12903. +
  12904. +static void
  12905. +test_renameat2_exchange (void)
  12906. +{
  12907. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12908. +
  12909. + glnx_autofd int srcfd = -1;
  12910. + glnx_autofd int destfd = -1;
  12911. + if (!renameat_test_setup (&srcfd, &destfd, error))
  12912. + return;
  12913. +
  12914. + if (glnx_renameat2_exchange (AT_FDCWD, "srcdir", AT_FDCWD, "destdir") < 0)
  12915. + return (void)glnx_throw_errno_prefix (error, "renameat");
  12916. +
  12917. + /* Ensure the dir fds are the same */
  12918. + struct stat stbuf;
  12919. + if (!glnx_fstatat (srcfd, "foo", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  12920. + return;
  12921. + if (!glnx_fstatat (destfd, "bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  12922. + return;
  12923. + /* But the dirs should be swapped */
  12924. + if (!glnx_fstatat (AT_FDCWD, "destdir/foo", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  12925. + return;
  12926. + if (!glnx_fstatat (AT_FDCWD, "srcdir/bar", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  12927. + return;
  12928. +}
  12929. +
  12930. +static void
  12931. +test_tmpfile (void)
  12932. +{
  12933. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12934. +
  12935. + g_auto(GLnxTmpfile) tmpf = { 0, };
  12936. + if (!glnx_open_tmpfile_linkable_at (AT_FDCWD, ".", O_WRONLY|O_CLOEXEC, &tmpf, error))
  12937. + return;
  12938. + if (glnx_loop_write (tmpf.fd, "foo", strlen ("foo")) < 0)
  12939. + return (void)glnx_throw_errno_prefix (error, "write");
  12940. + if (glnx_link_tmpfile_at (&tmpf, GLNX_LINK_TMPFILE_NOREPLACE, AT_FDCWD, "foo", error))
  12941. + return;
  12942. +}
  12943. +
  12944. +static void
  12945. +test_stdio_file (void)
  12946. +{
  12947. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12948. + g_auto(GLnxTmpfile) tmpf = { 0, };
  12949. + g_autoptr(FILE) f = NULL;
  12950. +
  12951. + if (!glnx_open_anonymous_tmpfile (O_RDWR|O_CLOEXEC, &tmpf, error))
  12952. + return;
  12953. + f = fdopen (tmpf.fd, "w");
  12954. + tmpf.fd = -1; /* Ownership was transferred via fdopen() */
  12955. + if (!f)
  12956. + return (void)glnx_throw_errno_prefix (error, "fdopen");
  12957. + if (fwrite ("hello", 1, strlen ("hello"), f) != strlen ("hello"))
  12958. + return (void)glnx_throw_errno_prefix (error, "fwrite");
  12959. + if (!glnx_stdio_file_flush (f, error))
  12960. + return;
  12961. +}
  12962. +
  12963. +static void
  12964. +test_fstatat (void)
  12965. +{
  12966. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12967. + struct stat stbuf = { 0, };
  12968. +
  12969. + if (!glnx_fstatat_allow_noent (AT_FDCWD, ".", &stbuf, 0, error))
  12970. + return;
  12971. + g_assert_cmpint (errno, ==, 0);
  12972. + g_assert_no_error (local_error);
  12973. + g_assert (S_ISDIR (stbuf.st_mode));
  12974. + if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchfile", &stbuf, 0, error))
  12975. + return;
  12976. + g_assert_cmpint (errno, ==, ENOENT);
  12977. + g_assert_no_error (local_error);
  12978. +
  12979. + /* test NULL parameter for stat */
  12980. + if (!glnx_fstatat_allow_noent (AT_FDCWD, ".", NULL, 0, error))
  12981. + return;
  12982. + g_assert_cmpint (errno, ==, 0);
  12983. + g_assert_no_error (local_error);
  12984. + if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchfile", NULL, 0, error))
  12985. + return;
  12986. + g_assert_cmpint (errno, ==, ENOENT);
  12987. + g_assert_no_error (local_error);
  12988. +}
  12989. +
  12990. +static void
  12991. +test_filecopy (void)
  12992. +{
  12993. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  12994. + const char foo[] = "foo";
  12995. + struct stat stbuf;
  12996. +
  12997. + if (!glnx_ensure_dir (AT_FDCWD, "subdir", 0755, error))
  12998. + return;
  12999. +
  13000. + if (!glnx_file_replace_contents_at (AT_FDCWD, foo, (guint8*)foo, sizeof (foo),
  13001. + GLNX_FILE_REPLACE_NODATASYNC, NULL, error))
  13002. + return;
  13003. +
  13004. + /* Copy it into both the same dir and a subdir */
  13005. + if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
  13006. + GLNX_FILE_COPY_NOXATTRS, NULL, error))
  13007. + return;
  13008. + if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "subdir/bar",
  13009. + GLNX_FILE_COPY_NOXATTRS, NULL, error))
  13010. + return;
  13011. + if (!glnx_fstatat (AT_FDCWD, "subdir/bar", &stbuf, 0, error))
  13012. + return;
  13013. +
  13014. + if (glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
  13015. + GLNX_FILE_COPY_NOXATTRS, NULL, error))
  13016. + g_assert_not_reached ();
  13017. + g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS);
  13018. + g_clear_error (&local_error);
  13019. +
  13020. + if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "bar",
  13021. + GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_OVERWRITE,
  13022. + NULL, error))
  13023. + return;
  13024. +
  13025. + if (symlinkat ("nosuchtarget", AT_FDCWD, "link") < 0)
  13026. + return (void) glnx_throw_errno_prefix (error, "symlinkat");
  13027. +
  13028. + /* Shouldn't be able to overwrite a symlink without GLNX_FILE_COPY_OVERWRITE */
  13029. + if (glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "link",
  13030. + GLNX_FILE_COPY_NOXATTRS,
  13031. + NULL, error))
  13032. + g_assert_not_reached ();
  13033. + g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS);
  13034. + g_clear_error (&local_error);
  13035. +
  13036. + /* Test overwriting symlink */
  13037. + if (!glnx_file_copy_at (AT_FDCWD, foo, NULL, AT_FDCWD, "link",
  13038. + GLNX_FILE_COPY_NOXATTRS | GLNX_FILE_COPY_OVERWRITE,
  13039. + NULL, error))
  13040. + return;
  13041. +
  13042. + if (!glnx_fstatat_allow_noent (AT_FDCWD, "nosuchtarget", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  13043. + return;
  13044. + g_assert_cmpint (errno, ==, ENOENT);
  13045. + g_assert_no_error (local_error);
  13046. +
  13047. + if (!glnx_fstatat (AT_FDCWD, "link", &stbuf, AT_SYMLINK_NOFOLLOW, error))
  13048. + return;
  13049. + g_assert (S_ISREG (stbuf.st_mode));
  13050. +}
  13051. +
  13052. +int main (int argc, char **argv)
  13053. +{
  13054. + int ret;
  13055. +
  13056. + g_test_init (&argc, &argv, NULL);
  13057. +
  13058. + g_test_add_func ("/tmpfile", test_tmpfile);
  13059. + g_test_add_func ("/stdio-file", test_stdio_file);
  13060. + g_test_add_func ("/filecopy", test_filecopy);
  13061. + g_test_add_func ("/renameat2-noreplace", test_renameat2_noreplace);
  13062. + g_test_add_func ("/renameat2-exchange", test_renameat2_exchange);
  13063. + g_test_add_func ("/fstat", test_fstatat);
  13064. +
  13065. + ret = g_test_run();
  13066. +
  13067. + return ret;
  13068. +}
  13069. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/test-libglnx-macros.c flatpak-1.0.0/libglnx/tests/test-libglnx-macros.c
  13070. --- flatpak-1.0.0.orig/libglnx/tests/test-libglnx-macros.c 1970-01-01 02:00:00.000000000 +0200
  13071. +++ flatpak-1.0.0/libglnx/tests/test-libglnx-macros.c 2018-02-03 21:26:06.309233341 +0300
  13072. @@ -0,0 +1,109 @@
  13073. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  13074. + *
  13075. + * Copyright (C) 2017 Red Hat, Inc.
  13076. + *
  13077. + * This library is free software; you can redistribute it and/or
  13078. + * modify it under the terms of the GNU Lesser General Public
  13079. + * License as published by the Free Software Foundation; either
  13080. + * version 2 of the License, or (at your option) any later version.
  13081. + *
  13082. + * This library is distributed in the hope that it will be useful,
  13083. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13084. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13085. + * Lesser General Public License for more details.
  13086. + *
  13087. + * You should have received a copy of the GNU Lesser General Public
  13088. + * License along with this library; if not, write to the
  13089. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  13090. + * Boston, MA 02111-1307, USA.
  13091. + */
  13092. +
  13093. +#include "config.h"
  13094. +#include "libglnx.h"
  13095. +#include <glib.h>
  13096. +#include <stdlib.h>
  13097. +#include <gio/gio.h>
  13098. +#include <string.h>
  13099. +
  13100. +static void
  13101. +test_inset (void)
  13102. +{
  13103. + g_assert (G_IN_SET (7, 7));
  13104. + g_assert (G_IN_SET (7, 42, 7));
  13105. + g_assert (G_IN_SET (7, 7,42,3,9));
  13106. + g_assert (G_IN_SET (42, 7,42,3,9));
  13107. + g_assert (G_IN_SET (3, 7,42,3,9));
  13108. + g_assert (G_IN_SET (9, 7,42,3,9));
  13109. + g_assert (!G_IN_SET (8, 7,42,3,9));
  13110. + g_assert (!G_IN_SET (-1, 7,42,3,9));
  13111. + g_assert (G_IN_SET ('x', 'a', 'x', 'c'));
  13112. + g_assert (!G_IN_SET ('y', 'a', 'x', 'c'));
  13113. +}
  13114. +
  13115. +static void
  13116. +test_hash_table_foreach (void)
  13117. +{
  13118. + /* use var names all different from the macro metavars to ensure proper
  13119. + * substitution */
  13120. + g_autoptr(GHashTable) table = g_hash_table_new (g_str_hash, g_str_equal);
  13121. + const char *keys[] = {"key1", "key2"};
  13122. + const char *vals[] = {"val1", "val2"};
  13123. + g_hash_table_insert (table, (gpointer)keys[0], (gpointer)vals[0]);
  13124. + g_hash_table_insert (table, (gpointer)keys[1], (gpointer)vals[1]);
  13125. +
  13126. + guint i = 0;
  13127. + GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, key, const char*, val)
  13128. + {
  13129. + g_assert_cmpstr (key, ==, keys[i]);
  13130. + g_assert_cmpstr (val, ==, vals[i]);
  13131. + i++;
  13132. + }
  13133. + g_assert_cmpuint (i, ==, 2);
  13134. +
  13135. + i = 0;
  13136. + GLNX_HASH_TABLE_FOREACH_IT (table, it, const char*, key, const char*, val)
  13137. + {
  13138. + g_hash_table_iter_remove (&it);
  13139. + break;
  13140. + }
  13141. + g_assert_cmpuint (g_hash_table_size (table), ==, 1);
  13142. +
  13143. + g_hash_table_insert (table, (gpointer)keys[1], (gpointer)vals[1]);
  13144. + g_assert_cmpuint (g_hash_table_size (table), ==, 1);
  13145. +
  13146. + g_hash_table_insert (table, (gpointer)keys[0], (gpointer)vals[0]);
  13147. + g_assert_cmpuint (g_hash_table_size (table), ==, 2);
  13148. +
  13149. + i = 0;
  13150. + GLNX_HASH_TABLE_FOREACH_KV (table, const char*, key, const char*, val)
  13151. + {
  13152. + g_assert_cmpstr (key, ==, keys[i]);
  13153. + g_assert_cmpstr (val, ==, vals[i]);
  13154. + i++;
  13155. + }
  13156. + g_assert_cmpuint (i, ==, 2);
  13157. +
  13158. + i = 0;
  13159. + GLNX_HASH_TABLE_FOREACH (table, const char*, key)
  13160. + {
  13161. + g_assert_cmpstr (key, ==, keys[i]);
  13162. + i++;
  13163. + }
  13164. + g_assert_cmpuint (i, ==, 2);
  13165. +
  13166. + i = 0;
  13167. + GLNX_HASH_TABLE_FOREACH_V (table, const char*, val)
  13168. + {
  13169. + g_assert_cmpstr (val, ==, vals[i]);
  13170. + i++;
  13171. + }
  13172. + g_assert_cmpuint (i, ==, 2);
  13173. +}
  13174. +
  13175. +int main (int argc, char **argv)
  13176. +{
  13177. + g_test_init (&argc, &argv, NULL);
  13178. + g_test_add_func ("/inset", test_inset);
  13179. + g_test_add_func ("/hash_table_foreach", test_hash_table_foreach);
  13180. + return g_test_run();
  13181. +}
  13182. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/test-libglnx-shutil.c flatpak-1.0.0/libglnx/tests/test-libglnx-shutil.c
  13183. --- flatpak-1.0.0.orig/libglnx/tests/test-libglnx-shutil.c 1970-01-01 02:00:00.000000000 +0200
  13184. +++ flatpak-1.0.0/libglnx/tests/test-libglnx-shutil.c 2018-05-26 00:50:25.435037228 +0300
  13185. @@ -0,0 +1,63 @@
  13186. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  13187. + *
  13188. + * Copyright © 2017 Endless Mobile, Inc.
  13189. + *
  13190. + * This library is free software; you can redistribute it and/or
  13191. + * modify it under the terms of the GNU Lesser General Public
  13192. + * License as published by the Free Software Foundation; either
  13193. + * version 2 of the License, or (at your option) any later version.
  13194. + *
  13195. + * This library is distributed in the hope that it will be useful,
  13196. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13197. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13198. + * Lesser General Public License for more details.
  13199. + *
  13200. + * You should have received a copy of the GNU Lesser General Public
  13201. + * License along with this library; if not, write to the
  13202. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  13203. + * Boston, MA 02111-1307, USA.
  13204. + */
  13205. +
  13206. +#include "config.h"
  13207. +#include "libglnx.h"
  13208. +#include <glib.h>
  13209. +#include <stdlib.h>
  13210. +#include <gio/gio.h>
  13211. +#include <err.h>
  13212. +#include <string.h>
  13213. +
  13214. +#include "libglnx-testlib.h"
  13215. +
  13216. +static void
  13217. +test_mkdir_p_enoent (void)
  13218. +{
  13219. + _GLNX_TEST_DECLARE_ERROR(local_error, error);
  13220. + glnx_autofd int dfd = -1;
  13221. +
  13222. + if (!glnx_ensure_dir (AT_FDCWD, "test", 0755, error))
  13223. + return;
  13224. + if (!glnx_opendirat (AT_FDCWD, "test", FALSE, &dfd, error))
  13225. + return;
  13226. + if (rmdir ("test") < 0)
  13227. + return (void) glnx_throw_errno_prefix (error, "rmdir(%s)", "test");
  13228. +
  13229. + /* This should fail with ENOENT. */
  13230. + glnx_shutil_mkdir_p_at (dfd, "blah/baz", 0755, NULL, error);
  13231. + g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND);
  13232. + g_clear_error (&local_error);
  13233. +}
  13234. +
  13235. +int
  13236. +main (int argc,
  13237. + char **argv)
  13238. +{
  13239. + int ret;
  13240. +
  13241. + g_test_init (&argc, &argv, NULL);
  13242. +
  13243. + g_test_add_func ("/mkdir-p/enoent", test_mkdir_p_enoent);
  13244. +
  13245. + ret = g_test_run();
  13246. +
  13247. + return ret;
  13248. +}
  13249. diff -Nuar flatpak-1.0.0.orig/libglnx/tests/test-libglnx-xattrs.c flatpak-1.0.0/libglnx/tests/test-libglnx-xattrs.c
  13250. --- flatpak-1.0.0.orig/libglnx/tests/test-libglnx-xattrs.c 1970-01-01 02:00:00.000000000 +0200
  13251. +++ flatpak-1.0.0/libglnx/tests/test-libglnx-xattrs.c 2018-05-26 00:50:25.435037228 +0300
  13252. @@ -0,0 +1,283 @@
  13253. +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
  13254. + *
  13255. + * Copyright (C) 2017 Red Hat, Inc.
  13256. + *
  13257. + * This library is free software; you can redistribute it and/or
  13258. + * modify it under the terms of the GNU Lesser General Public
  13259. + * License as published by the Free Software Foundation; either
  13260. + * version 2 of the License, or (at your option) any later version.
  13261. + *
  13262. + * This library is distributed in the hope that it will be useful,
  13263. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13264. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13265. + * Lesser General Public License for more details.
  13266. + *
  13267. + * You should have received a copy of the GNU Lesser General Public
  13268. + * License along with this library; if not, write to the
  13269. + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  13270. + * Boston, MA 02111-1307, USA.
  13271. + */
  13272. +
  13273. +#include "config.h"
  13274. +#include "libglnx.h"
  13275. +#include <glib.h>
  13276. +#include <stdlib.h>
  13277. +#include <gio/gio.h>
  13278. +#include <string.h>
  13279. +
  13280. +#define XATTR_THREAD_RUN_TIME_USECS (5 * G_USEC_PER_SEC)
  13281. +
  13282. +struct XattrWorker {
  13283. + int dfd;
  13284. + gboolean is_writer;
  13285. + guint n_attrs_read;
  13286. +};
  13287. +
  13288. +typedef enum {
  13289. + WRITE_RUN_MUTATE,
  13290. + WRITE_RUN_CREATE,
  13291. +} WriteType;
  13292. +
  13293. +static gboolean
  13294. +set_random_xattr_value (int fd, const char *name, GError **error)
  13295. +{
  13296. + const guint8 randxattrbyte = g_random_int_range (0, 256);
  13297. + const guint32 randxattrvalue_len = (g_random_int () % 256) + 1; /* Picked to be not too small or large */
  13298. + g_autofree char *randxattrvalue = g_malloc (randxattrvalue_len);
  13299. +
  13300. + memset (randxattrvalue, randxattrbyte, randxattrvalue_len);
  13301. +
  13302. + if (fsetxattr (fd, name, randxattrvalue, randxattrvalue_len, 0) < 0)
  13303. + {
  13304. + glnx_set_error_from_errno (error);
  13305. + return FALSE;
  13306. + }
  13307. +
  13308. + return TRUE;
  13309. +}
  13310. +
  13311. +static gboolean
  13312. +add_random_xattrs (int fd, GError **error)
  13313. +{
  13314. + const guint nattrs = MIN (2, g_random_int () % 16);
  13315. +
  13316. + for (guint i = 0; i < nattrs; i++)
  13317. + {
  13318. + guint32 randxattrname_v = g_random_int ();
  13319. + g_autofree char *randxattrname = g_strdup_printf ("user.test%u", randxattrname_v);
  13320. +
  13321. + if (!set_random_xattr_value (fd, randxattrname, error))
  13322. + return FALSE;
  13323. + }
  13324. +
  13325. + return TRUE;
  13326. +}
  13327. +
  13328. +static gboolean
  13329. +do_write_run (GLnxDirFdIterator *dfd_iter, GError **error)
  13330. +{
  13331. + WriteType wtype = g_random_int () % 2;
  13332. +
  13333. + if (wtype == WRITE_RUN_CREATE)
  13334. + {
  13335. + guint32 randname_v = g_random_int ();
  13336. + g_autofree char *randname = g_strdup_printf ("file%u", randname_v);
  13337. + glnx_autofd int fd = -1;
  13338. +
  13339. + again:
  13340. + fd = openat (dfd_iter->fd, randname, O_CREAT | O_EXCL, 0644);
  13341. + if (fd < 0)
  13342. + {
  13343. + if (errno == EEXIST)
  13344. + {
  13345. + g_printerr ("Congratulations! I suggest purchasing a lottery ticket today!\n");
  13346. + goto again;
  13347. + }
  13348. + else
  13349. + {
  13350. + glnx_set_error_from_errno (error);
  13351. + return FALSE;
  13352. + }
  13353. + }
  13354. +
  13355. + if (!add_random_xattrs (fd, error))
  13356. + return FALSE;
  13357. + }
  13358. + else if (wtype == WRITE_RUN_MUTATE)
  13359. + {
  13360. + while (TRUE)
  13361. + {
  13362. + struct dirent *dent;
  13363. + if (!glnx_dirfd_iterator_next_dent (dfd_iter, &dent, NULL, error))
  13364. + return FALSE;
  13365. + if (!dent)
  13366. + break;
  13367. +
  13368. + glnx_autofd int fd = -1;
  13369. + if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
  13370. + return FALSE;
  13371. +
  13372. + g_autoptr(GVariant) current_xattrs = NULL;
  13373. + if (!glnx_fd_get_all_xattrs (fd, &current_xattrs, NULL, error))
  13374. + return FALSE;
  13375. +
  13376. + for (int i = 0; i < g_variant_n_children (current_xattrs); i++)
  13377. + {
  13378. + const char *name, *value;
  13379. + g_variant_get_child (current_xattrs, i, "(^&ay^&ay)", &name, &value);
  13380. +
  13381. + /* We don't want to potentially test/change xattrs like security.selinux
  13382. + * that were injected by the system.
  13383. + */
  13384. + if (!g_str_has_prefix (name, "user.test"))
  13385. + continue;
  13386. +
  13387. + if (!set_random_xattr_value (fd, name, error))
  13388. + return FALSE;
  13389. + }
  13390. + }
  13391. + }
  13392. + else
  13393. + g_assert_not_reached ();
  13394. +
  13395. + return TRUE;
  13396. +}
  13397. +
  13398. +static gboolean
  13399. +do_read_run (GLnxDirFdIterator *dfd_iter,
  13400. + guint *out_n_read,
  13401. + GError **error)
  13402. +{
  13403. + guint nattrs = 0;
  13404. + while (TRUE)
  13405. + {
  13406. + struct dirent *dent;
  13407. + if (!glnx_dirfd_iterator_next_dent (dfd_iter, &dent, NULL, error))
  13408. + return FALSE;
  13409. + if (!dent)
  13410. + break;
  13411. +
  13412. + glnx_autofd int fd = -1;
  13413. + if (!glnx_openat_rdonly (dfd_iter->fd, dent->d_name, FALSE, &fd, error))
  13414. + return FALSE;
  13415. +
  13416. + g_autoptr(GVariant) current_xattrs = NULL;
  13417. + if (!glnx_fd_get_all_xattrs (fd, &current_xattrs, NULL, error))
  13418. + return FALSE;
  13419. +
  13420. + /* We don't actually care about the values, just use the variable
  13421. + * to avoid compiler warnings.
  13422. + */
  13423. + nattrs += g_variant_n_children (current_xattrs);
  13424. + }
  13425. +
  13426. + *out_n_read = nattrs;
  13427. + return TRUE;
  13428. +}
  13429. +
  13430. +static gpointer
  13431. +xattr_thread (gpointer data)
  13432. +{
  13433. + g_autoptr(GError) local_error = NULL;
  13434. + GError **error = &local_error;
  13435. + struct XattrWorker *worker = data;
  13436. + guint64 end_time = g_get_monotonic_time () + XATTR_THREAD_RUN_TIME_USECS;
  13437. + guint n_read = 0;
  13438. +
  13439. + while (g_get_monotonic_time () < end_time)
  13440. + {
  13441. + g_auto(GLnxDirFdIterator) dfd_iter = { 0, };
  13442. +
  13443. + if (!glnx_dirfd_iterator_init_at (worker->dfd, ".", TRUE, &dfd_iter, error))
  13444. + goto out;
  13445. +
  13446. + if (worker->is_writer)
  13447. + {
  13448. + if (!do_write_run (&dfd_iter, error))
  13449. + goto out;
  13450. + }
  13451. + else
  13452. + {
  13453. + if (!do_read_run (&dfd_iter, &n_read, error))
  13454. + goto out;
  13455. + }
  13456. + }
  13457. +
  13458. + out:
  13459. + g_assert_no_error (local_error);
  13460. +
  13461. + return GINT_TO_POINTER (n_read);
  13462. +}
  13463. +
  13464. +static void
  13465. +test_xattr_races (void)
  13466. +{
  13467. + /* If for some reason we're built in a VM which only has one vcpu, let's still
  13468. + * at least make the test do something.
  13469. + */
  13470. + /* FIXME - this deadlocks for me on 4.9.4-201.fc25.x86_64, whether
  13471. + * using overlayfs or xfs as source/dest.
  13472. + */
  13473. + const guint nprocs = MAX (4, g_get_num_processors ());
  13474. + struct XattrWorker wdata[nprocs];
  13475. + GThread *threads[nprocs];
  13476. + g_autoptr(GError) local_error = NULL;
  13477. + GError **error = &local_error;
  13478. + g_auto(GLnxTmpDir) tmpdir = { 0, };
  13479. + g_autofree char *tmpdir_path = g_strdup_printf ("%s/libglnx-xattrs-XXXXXX",
  13480. + getenv ("TMPDIR") ?: "/var/tmp");
  13481. + guint nread = 0;
  13482. +
  13483. + if (!glnx_mkdtempat (AT_FDCWD, tmpdir_path, 0700,
  13484. + &tmpdir, error))
  13485. + goto out;
  13486. +
  13487. + /* Support people building/testing on tmpfs https://github.com/flatpak/flatpak/issues/686 */
  13488. + if (fsetxattr (tmpdir.fd, "user.test", "novalue", strlen ("novalue"), 0) < 0)
  13489. + {
  13490. + if (errno == EOPNOTSUPP)
  13491. + {
  13492. + g_test_skip ("no xattr support");
  13493. + return;
  13494. + }
  13495. + else
  13496. + {
  13497. + glnx_set_error_from_errno (error);
  13498. + goto out;
  13499. + }
  13500. + }
  13501. +
  13502. + for (guint i = 0; i < nprocs; i++)
  13503. + {
  13504. + struct XattrWorker *worker = &wdata[i];
  13505. + worker->dfd = tmpdir.fd;
  13506. + worker->is_writer = i % 2 == 0;
  13507. + threads[i] = g_thread_new (NULL, xattr_thread, worker);
  13508. + }
  13509. +
  13510. + for (guint i = 0; i < nprocs; i++)
  13511. + {
  13512. + if (wdata[i].is_writer)
  13513. + (void) g_thread_join (threads[i]);
  13514. + else
  13515. + nread += GPOINTER_TO_UINT (g_thread_join (threads[i]));
  13516. + }
  13517. +
  13518. + g_print ("Read %u xattrs race free!\n", nread);
  13519. +
  13520. + out:
  13521. + g_assert_no_error (local_error);
  13522. +}
  13523. +
  13524. +int main (int argc, char **argv)
  13525. +{
  13526. + int ret;
  13527. +
  13528. + g_test_init (&argc, &argv, NULL);
  13529. +
  13530. + g_test_add_func ("/xattr-races", test_xattr_races);
  13531. +
  13532. + ret = g_test_run();
  13533. +
  13534. + return ret;
  13535. +}