├── COPYING ├── ChangeLog ├── README ├── distros ├── arch │ └── sandfox │ │ └── PKGBUILD └── debian │ ├── sandfox-initd │ └── sandfox.ctl └── sandfox /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | # 1.1.4: chroot discovery 2 | # added Firefox and Skype bindro=/home/\$user/.asoundrc 3 | # 1.1.3: added bindro /run/resolvconf to default Firefox profile 4 | # 1.1.2: accomodate change to remount bind usage 5 | # accomodate change to mtab bind mounts showing type 6 | # added /dev/nvidia0 & /dev/nvidiactl binds to default profiles 7 | # added bindro=/opt/firefox to default firefox profile 8 | # improved detection for 'firefox already running' warning 9 | # 1.1.1: accomodate recent change to ps line endings 10 | # 1.1.0: kills dbus-launch inside sandboxes before closing (lsof required) 11 | # 1.0.10: use tmpfs instead of none for mount source (due to new util-linux) 12 | # skype profile adds /opt/skype and disable note for Gentoo users 13 | # 1.0.9: permissions on mnt folders 14 | # removed uuidgen dependency 15 | # determine sandbox user with Xauthority 16 | # added default google-earth profile 17 | # 1.0.8: modification of daemon detection for non-standard ps 18 | # non-existent --sandbox triggers make 19 | # corrected --status mount count 20 | # 1.0.7: added /dev/video0 to skype profile (replaces /dev/video) 21 | # added disabled Lockdown X Access section to default profile 22 | # 1.0.6: added firefox bindro for ~/.Xauthority 23 | # added warning if firefox already running 24 | # 1.0.5: modification of daemon detection for non-standard ps 25 | # 1.0.4: corrected detection of running daemon with --verbose and --logfile 26 | # 1.0.3: corrected problems with sandboxes with similar names 27 | # 1.0.2: hide non-existent folder corrected 28 | # 1.0.0: handle /dev/urandom like /dev/random to prevent hangs 29 | # 0.9.6: Changed tmpfslimit to 100M 30 | # now allows successful bind=/dev/random for Firefox printing 31 | # added user-contributed skype profile (experimental) 32 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README for sandfox 2 | 3 | 4 | OVERVIEW 5 | ======== 6 | 7 | Sandfox runs programs within sandboxes which limit the programs’ access to only 8 | the folders you specify. Programs and their child processes, like Firefox 9 | plugins, Flash, and Java, are only able to access files within the sandbox. 10 | Sandfox supports the use of custom profiles which determine what folders and 11 | files are included in each program’s sandbox, and includes default profiles for 12 | Firefox, Skype, and Google-Earth. Sandfox can create separate sandboxes for 13 | each program, or can run multiple programs in one sandbox. Programs are run in 14 | a chroot jail as a normal user, providing a substantial level of security. 15 | Sandfox is designed to be very easy to use. It handles the details for you 16 | while still giving you the ability to construct custom sandboxes easily. 17 | 18 | Homepage & Instructions: 19 | http://igurublog.wordpress.com/downloads/script-sandfox/ 20 | 21 | Downloads: 22 | https://github.com/IgnorantGuru/sandfox/tags 23 | https://github.com/IgnorantGuru/sandfox/tree/master/packages 24 | 25 | Debian/Ubuntu PPA: 26 | http://igurublog.wordpress.com/downloads/ppa/ 27 | 28 | Bug Reports: 29 | https://github.com/IgnorantGuru/sandfox/issues 30 | 31 | 32 | INSTALLATION 33 | ============ 34 | 35 | To install: 36 | 37 | wget https://github.com/IgnorantGuru/sandfox/raw/master/sandfox 38 | sudo install sandfox /usr/local/bin/sandfox 39 | 40 | sandfox also REQUIRES: inotify-tools lsof 41 | 42 | If using SpaceFM see: 43 | http://igurublog.wordpress.com/downloads/script-sandfox/#spacefm 44 | 45 | To remove sandfox: 46 | 47 | sudo rm /usr/local/bin/sandfox 48 | 49 | 50 | LICENSE 51 | ======= 52 | 53 | This program is free software: you can redistribute it and/or modify 54 | it under the terms of the GNU General Public License as published by 55 | the Free Software Foundation, either version 3 of the License, or 56 | (at your option) any later version. 57 | 58 | This program is distributed in the hope that it will be useful, 59 | but WITHOUT ANY WARRANTY; without even the implied warranty of 60 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 61 | GNU General Public License for more details. 62 | 63 | You should have received a copy of the GNU General Public License 64 | along with this program. If not, see . 65 | 66 | -------------------------------------------------------------------------------- /distros/arch/sandfox/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Maintainer: IgnorantGuru http://igurublog.wordpress.com/contact-ignorantguru/ 2 | 3 | pkgname=sandfox 4 | pkgver=20131018 5 | pkgrel=1 6 | pkgdesc="Runs Firefox and other apps in a sandbox with limited access to the filesystem" 7 | arch=(any) 8 | license=('GPL3') 9 | url=("http://igurublog.wordpress.com/downloads/script-$pkgname/") 10 | depends=('inotify-tools') 11 | makedepends=('git') 12 | source=('git://github.com/IgnorantGuru/sandfox.git') 13 | md5sums=('SKIP') 14 | 15 | pkgver() { 16 | cd "$pkgname" 17 | git describe --always | sed 's|-|.|g' 18 | } 19 | 20 | package() { 21 | cd "$pkgname" 22 | install -Dm755 "$pkgname" "$pkgdir/usr/bin/$pkgname" 23 | } 24 | -------------------------------------------------------------------------------- /distros/debian/sandfox-initd: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Sandfox boot startup script for Ubuntu and similar 3 | 4 | sandfoxuser=myuser 5 | sandfoxprofile=firefox 6 | sandfoxbin=/usr/local/bin/sandfox 7 | 8 | start() { 9 | echo -n "Starting Sandfox: " 10 | $sandfoxbin --profile $sandfoxprofile --user $sandfoxuser 11 | if [ $? -gt 0 ]; then 12 | echo "failure" 13 | RETVAL=$? 14 | else 15 | echo "success" 16 | RETVAL=0 17 | fi 18 | } 19 | 20 | stop() { 21 | echo -n "Stopping Sandfox: " 22 | $sandfoxbin --closeall --user $sandfoxuser 23 | if [ $? -gt 0 ]; then 24 | echo "failure" 25 | RETVAL=$? 26 | else 27 | echo "success" 28 | RETVAL=0 29 | fi 30 | } 31 | 32 | case "$1" in 33 | start) 34 | start 35 | ;; 36 | stop) 37 | stop 38 | ;; 39 | restart) 40 | stop 41 | sleep 3 42 | start 43 | ;; 44 | *) 45 | echo "Usage: $0 {start|stop|restart}" 46 | RETVAL=1 47 | esac 48 | exit $RETVAL 49 | 50 | -------------------------------------------------------------------------------- /distros/debian/sandfox.ctl: -------------------------------------------------------------------------------- 1 | Section: utils 2 | Package: sandfox 3 | Description: Runs Firefox and other apps in a filesystem sandbox 4 | Sandfox runs programs within sandboxes. Programs and their child processes, 5 | like Firefox plugins, Flash, and Java, are only able to access files within 6 | the sandbox. Sandfox supports the use of custom profiles and includes 7 | default profiles for Firefox, Skype, and Google-Earth. 8 | Copyright: COPYING 9 | Changelog: changelog 10 | Readme: README 11 | Depends: inotify-tools, lsof 12 | Files: sandfox /usr/bin/ 13 | -------------------------------------------------------------------------------- /sandfox: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Script Name: sandfox http://igurublog.wordpress.com/downloads/script-sandfox/ 3 | # Requires: inotify-tools 4 | # License: GNU GENERAL PUBLIC LICENSE Version 3 http://www.gnu.org/licenses/gpl-3.0.txt 5 | 6 | help () 7 | { 8 | cat << EOF 9 | sandfox version 1.1.4 10 | Usage: sandfox [OPTIONS] [COMMAND [ARG]...] 11 | Runs COMMAND as a normal user within a chroot jail sandbox with limited 12 | access to the filesystem. Supports profiles for apps and includes a default 13 | Firefox profile. Must be run as root when creating sandbox. Examples: 14 | sudo sandfox firefox # Runs Firefox in a sandbox 15 | sudo sandfox bash # Shell to explore a sandbox 16 | OPTIONS: 17 | --bindro TARGET Include TARGET (a file or folder) in the sandbox 18 | bind-mounting it as a read-only filesystem 19 | --bind TARGET Include TARGET (a file or folder) in the sandbox 20 | with same ownership and permissions when possible 21 | --copy TARGET Place a disposable copy of TARGET (a file or folder) 22 | in the sandbox 23 | --hide TARGET Include TARGET (a file or folder) in the sandbox 24 | by bind-mounting an empty file or folder onto it 25 | Effectively hides the real TARGET from the sandbox 26 | Also provides a writable dummy folder 27 | --profile PROFILE Load PROFILE (a profile name or pathname). By 28 | default profiles are stored in $defaultprofolder 29 | --make Force creation or update of a sandbox (make is 30 | implied if you specify binds or profiles) 31 | --sandbox NAME Specify name of sandbox to use, create, or update 32 | --close NAME Unmount and remove sandbox NAME 33 | --closeall Unmount and remove ALL sandboxes 34 | --status Show the status of all current sandboxes 35 | --shell Run COMMAND in a shell and wait. Requires root. 36 | (bash is always run in a shell) 37 | --user USERNAME Run command as USER in the sandbox - useful if 38 | auto-detection does not work or to override 39 | --profilefolder FOLDER Use FOLDER instead of the default profile folder 40 | IMPORTANT: should be root owned & write-protected 41 | --logfile LOGFILE Also append messages to LOGFILE. sandfox daemons 42 | will also update this file provided it is 43 | accessible from within the sandbox. 44 | --verbose Provide detailed feedback 45 | --quiet Minimize output messages 46 | NOTES: OPTIONS must precede COMMAND; you can also use OPTION=VALUE; binds are 47 | processed in this order: bindro bind copy hide; missing binds are ignored; if 48 | a profile for COMMAND exists it will be automatically loaded; default profile 49 | is always loaded; profiles may contain any options valid on the command line; 50 | if COMMAND is omitted, a sandbox will be created for use. 51 | Instructions and updates: 52 | http://igurublog.wordpress.com/downloads/script-sandfox/ 53 | 54 | EOF 55 | exit 0 56 | } 57 | 58 | log () { 59 | output=0 60 | if (( optquiet == 1 )) && [ "$2" = "quiet" ]; then 61 | output=1 62 | elif (( optverbose == 1 )) && [ "$2" = "verb" ]; then 63 | output=1 64 | elif (( optquiet == 0 )) && [ "$2" != "verb" ]; then 65 | output=1 66 | fi 67 | if (( output == 1 )); then 68 | if (( optdaemon == 1 )); then 69 | d="sandfox-daemon($(basename "${watchs[0]}")): " 70 | else 71 | d="" 72 | fi 73 | echo "$1" 74 | if [ "$logfile" != "" ]; then 75 | echo "$(date '+%Y-%m-%d %H:%M:%S'): $d$1" >> "$logfile" 76 | fi 77 | fi 78 | } 79 | 80 | processopt () { # $1 $2 81 | # Process a command line or profile option 82 | opt="$1" 83 | opt2="$2" 84 | shifts=2 85 | if [ "${opt:0:2}" = "--" ]; then 86 | opt="${opt:2}" 87 | fi 88 | case "$opt" in 89 | help | -help | -h ) 90 | help 91 | exit 92 | ;; 93 | bind | bindrw | bindro | hide | copy | watch ) 94 | if [ "${opt2:0:1}" != "/" ]; then 95 | log "$curprofile: Option $opt $opt2" "verb" 96 | log "$curprofile: Error: Option $opt requires an absolute path" "quiet" 97 | exit 1 98 | fi 99 | if [ "$opt" = "bindrw" ]; then 100 | opt="bind" 101 | fi 102 | eval $opt\s[\$$opt\scnt]=\"\$opt2\" 103 | eval \(\( $opt\scnt += 1 \)\) 104 | ;; 105 | profile ) 106 | if [ "${opt2:0:1}" = "-" ]; then 107 | log "$curprofile: Option $opt $opt2" "verb" 108 | log "$curprofile: Error: Option $opt requires a profile name or file" "quiet" 109 | exit 1 110 | fi 111 | prof[$profcnt]="$opt2" 112 | (( profcnt += 1 )) 113 | ;; 114 | profilefolder ) 115 | if [ "$profolder" != "" ]; then 116 | log "$curprofile: Option $opt $opt2" "verb" 117 | log "$curprofile: Error: Multiple profile folders not permitted" "quiet" 118 | exit 1 119 | elif [ "${opt2:0:1}" != "/" ]; then 120 | log "$curprofile: Option $opt $opt2" "verb" 121 | log "$curprofile: Error: Option $opt requires an absolute path" "quiet" 122 | exit 1 123 | fi 124 | profolder="$opt2" 125 | ;; 126 | sandbox ) 127 | if [ "$sandbox" != "" ]; then 128 | log "$curprofile: Option $opt $opt2" "verb" 129 | log "$curprofile: Error: Multiple sandbox names not permitted" "quiet" 130 | exit 1 131 | fi 132 | opt2base=`basename "$opt2"` 133 | if [ "${opt2:0:1}" = "-" ] || [ "$opt2" = "" ] || [ "$opt2" != "$opt2base" ]; then 134 | log "$curprofile: Option $opt $opt2" "verb" 135 | log "$curprofile: Error: Option $opt requires a sandbox name" "quiet" 136 | exit 1 137 | fi 138 | sandbox="$opt2" 139 | ;; 140 | close ) 141 | opt2base=`basename "$opt2"` 142 | if [ "${opt2:0:1}" = "-" ] || [ "$opt2" = "" ] || [ "$opt2" != "$opt2base" ]; then 143 | log "$curprofile: Option $opt $opt2" "verb" 144 | log "$curprofile: Error: Option $opt requires a sandbox name" "quiet" 145 | exit 1 146 | fi 147 | closename[$closecnt]="$2" 148 | (( closecnt += 1 )) 149 | ;; 150 | logfile ) 151 | if [ "${opt2:0:1}" != "/" ]; then 152 | log "$curprofile: Option $opt $opt2" "verb" 153 | log "$curprofile: Error: Option $opt requires an absolute path" "quiet" 154 | exit 1 155 | fi 156 | if [ "$logfile" != "" ]; then 157 | log "$curprofile: Warning: Multiple log files ignored" "quiet" 158 | else 159 | logfile="$opt2" 160 | if (( optdaemon == 0 )); then 161 | echo "=======================================================================" >> "$logfile" 162 | echo "sandfox started $(date +%Y-%m-%d' '%H:%M:%S) on $HOSTNAME" >> "$logfile" 163 | echo "$logcl" >> "$logfile" 164 | else 165 | log "Started >>> $logcl" 166 | fi 167 | chmod go+rw "$logfile" 2> /dev/null 168 | fi 169 | ;; 170 | make | verbose | quiet | keepsand | clean | closeall | status | daemon | shell ) 171 | eval opt$opt=1 172 | if (( optquiet + optverbose == 2 )); then 173 | optquiet=0 174 | fi 175 | shifts=1 176 | ;; 177 | user ) 178 | if [ "${opt2:0:1}" = "-" ]; then 179 | log "$curprofile: Option $opt $opt2" "verb" 180 | log "$curprofile: Error: Option $opt requires a username" "quiet" 181 | exit 1 182 | fi 183 | if [ "$curprofile" = "commandline" ]; then 184 | user="$opt2" 185 | else 186 | log "$curprofile: Warning: Option $opt ignored in profile" 187 | fi 188 | ;; 189 | * ) 190 | log "$curprofile: Option $opt $opt2" "verb" 191 | log "$curprofile: Error: Unknown option $opt" "quiet" 192 | exit 1 193 | ;; 194 | esac 195 | if (( shifts == 2 )); then 196 | log "$curprofile: Option $opt $opt2" "verb" 197 | else 198 | log "$curprofile: Option $opt" "verb" 199 | fi 200 | return $shifts 201 | } 202 | 203 | loadprofile () { # $1=profile name or path 204 | p="$1" 205 | # exists? 206 | if [ "${p:0:1}" != "/" ]; then 207 | test1=`basename "$p"` 208 | test2=`basename "$p" "profile"` 209 | if [ "$test1" = "$test2" ]; then 210 | p="$profolder/$p.profile" 211 | else 212 | p="$profolder/$p" 213 | fi 214 | fi 215 | if [ ! -e "$p" ]; then 216 | log "sandfox: Error: Missing profile $p" "quiet" 217 | exit 3 218 | fi 219 | # already loaded? 220 | loadedprofidx=0 221 | load=1 222 | while (( loadedprofidx < loadedprofcnt )); do 223 | if [ "$p" = "${loadedprof[$loadedprofidx]}" ]; then 224 | load=0 225 | break 226 | fi 227 | (( loadedprofidx += 1 )) 228 | done 229 | if (( load == 1 )); then 230 | curprofile="$p" # global var 231 | loadedprof[$loadedprofcnt]="$p" 232 | (( loadedprofcnt += 1 )) 233 | # read profile 234 | log "Loading profile \"$1\"" 235 | IFS=$'\n' 236 | loadedopts=`grep -v -e "^[[:blank:]]*#" "$p"` 237 | for l in $loadedopts ; do 238 | lorg="$l" 239 | if [ "$l" != "" ]; then 240 | l2=${l#*=} 241 | if [ "$l" != "$l2" ]; then 242 | # split = into two opts 243 | l=${l%%=*} 244 | else 245 | l2="" 246 | fi 247 | # remove whitespace and comments 248 | while [[ $"${l:0:1}" =~ [[:blank:]] ]]; do 249 | l="${l:1}" 250 | done 251 | l=${l%%#*} 252 | lenl=${#l} 253 | (( lenl -= 1 )) 254 | while [[ $"${l:lenl:1}" =~ [[:blank:]] ]]; do 255 | l="${l:0:lenl}" 256 | lenl=${#l} 257 | (( lenl -= 1 )) 258 | done 259 | l=${l%%[[:blank:]]} 260 | while [[ $"${l2:0:1}" =~ [[:blank:]] ]]; do 261 | l2="${l2:1}" 262 | done 263 | l2=${l2%%#*} 264 | lenl2=${#l2} 265 | (( lenl2 -= 1 )) 266 | while [[ $"${l2:lenl2:1}" =~ [[:blank:]] ]]; do 267 | l2="${l2:0:lenl2}" 268 | lenl2=${#l2} 269 | (( lenl2 -= 1 )) 270 | done 271 | # process 272 | if [ "$l" != "" ]; then 273 | processopt "$l" "$l2" 274 | elif [ "$l2" != "" ]; then 275 | log "sandfox: Syntax error in profile $p" "quiet" 276 | log " Line: $lorg" "quiet" 277 | exit 3 278 | fi 279 | fi 280 | done 281 | IFS=" " 282 | fi 283 | } 284 | 285 | randhex4() # generate a four digit random hex number 286 | { 287 | rand1=$RANDOM 288 | rand2=$RANDOM 289 | (( rand = rand1 + rand2 )) 290 | let "rand %= 65536" 291 | randhex=`printf "%04X" $rand | tr A-Z a-z` 292 | if [ "$randhex" = "" ]; then 293 | randhex=$RANDOM # failsafe 294 | fi 295 | } 296 | 297 | rmbox () { # $1=mnt folder to remove 298 | if [ "$1" = "" ]; then 299 | return 300 | elif [ ! -d "$1" ]; then 301 | return 302 | fi 303 | cleanpath="$1" 304 | IFS=$'\n' 305 | 306 | # find dbus daemon(s) running in sandbox(s) 307 | # If DBUS_SESSION_BUS_ADDRESS is not provided, firefox will 308 | # launch a dbus session inside the sandbox. This needs to be killed 309 | # for the sandbox to be closed. 310 | if [ "$cleanpath" != "$mnt" ]; then 311 | # single sandbox 312 | dbuspids=`lsof -w 2> /dev/null | grep $cleanpath/usr/bin/dbus-launch$ | awk '{print $2}'` 313 | else 314 | # all sandboxes 315 | dbuspids=`lsof -w 2> /dev/null | grep $cleanpath/.*/usr/bin/dbus-launch$ | awk '{print $2}'` 316 | fi 317 | # kill dbus-launch in sandbox(s) 318 | for dpid in $dbuspids ; do 319 | log ">>> kill $dpid # kill dbus-launch in sandbox" "verb" 320 | kill $dpid 321 | sleep 1 322 | tries=0 323 | while (( tries < 20 )) && [ "$(ps -o pid= -p $dpid)" != "" ]; do 324 | if (( tries == 0 )); then 325 | log "Waiting for dbus-launch ($dpid) to terminate..." 326 | fi 327 | sleep .5 328 | (( tries++ )) 329 | done 330 | done 331 | 332 | # get mount points in reverse order 333 | mname="$cleanpath" 334 | mname=${mname//\//\\\/} # convert slashes 335 | mtab=`mount | grep " on $cleanpath\/" | sed "s/.* on \($mname.*\) type .*/\1/" | tac` 336 | if [ "$mtab" != "" ]; then 337 | # umount in reverse order 338 | for m in $mtab ; do 339 | log ">>> umount \"$m\"" "verb" 340 | test=`umount "$m" 2>&1` 341 | if [ "$?" != "0" ]; then 342 | log "$test" 343 | log "sandfox: Error: Closure incomplete - mounts may still exist on" "quiet" 344 | log " $cleanpath Close programs running in" "quiet" 345 | log " the sandbox and try again. If problem persists see output of:" "quiet" 346 | log " lsof -w | grep $cleanpath" 347 | exit 4 348 | fi 349 | done 350 | # do safety checks then remove folder 351 | mounts=`mount | grep " on $cleanpath\/" | sed "s/.* on \($mname.*\) type .*/\1/"` 352 | f1=`find "$cleanpath" -xdev -type f | wc -l 2> /dev/null` 353 | f2=`find "$cleanpath" -type f | wc -l 2> /dev/null` 354 | if [ "$f1" != "$f2" ] && [ "$mounts" = "" ]; then 355 | log "sandfox: Error: Not all files could be safely removed from $cleanpath" "quiet" 356 | log " This may indicate a hidden bind mount still exists. It is" "quiet" 357 | log " recommended that you reboot or backup original folders, then" "quiet" 358 | log " manually remove $cleanpath as root." "quiet" 359 | exit 4 360 | elif (( f1 > 50 )) && [ "$mounts" = "" ]; then 361 | log "sandfox: Error: Not all files could be safely removed from $cleanpath" "quiet" 362 | log " because the number of files remaining exceeds the safety limit" "quiet" 363 | log " of 50. It is recommended that you reboot or backup original" "quiet" 364 | log " folders, then manually remove $cleanpath as root." "quiet" 365 | exit 4 366 | elif [ "$mounts" != "" ]; then 367 | log "sandfox: Error: Closure incomplete - mounts still exist on" "quiet" 368 | log " $cleanpath Close programs running in" "quiet" 369 | log " the sandbox and try again. Mounts:" "quiet" 370 | log "$mounts" "quiet" 371 | exit 4 372 | else 373 | log "Removing $cleanpath" "verb" 374 | log ">>> find \"$cleanpath\" -xdev | sort -r" "verb" 375 | f1=`find "$cleanpath" -xdev | sort -r 2> /dev/null` 376 | if [ "$f1" != "" ]; then 377 | for f in $f1 ; do 378 | if [ -d "$f" ]; then 379 | rmdir "$f" 380 | else 381 | rm "$f" 382 | fi 383 | done 384 | fi 385 | if [ -e "$cleanpath" ]; then 386 | log "sandfox: Error: Not all files could be safely removed from $cleanpath" "quiet" 387 | log " This may indicate a hidden bind mount. It is recommended" "quiet" 388 | log " that you reboot or backup original folders before" "quiet" 389 | log " manually removing $cleanpath as root." "quiet" 390 | exit 4 391 | fi 392 | fi 393 | fi 394 | IFS=" " 395 | } 396 | 397 | mkmount () { # $1=original folder 398 | # make mount point 399 | odir="$1" 400 | fdir="$sand$1" 401 | mkdir -p "$fdir" 2> /dev/null 402 | # recursively copy original folder ownership & permissions 403 | while [ "$odir" != "" ]; do 404 | if [ -e "$odir" ]; then 405 | chmod --reference="$odir" "$fdir" 2> /dev/null 406 | chown --reference="$odir" "$fdir" 2> /dev/null 407 | else 408 | chmod ugo+rwx "$fdir" 2> /dev/null 409 | chown $user:$user "$fdir" 2> /dev/null 410 | fi 411 | odir=${odir%/*} 412 | fdir=${fdir%/*} 413 | done 414 | } 415 | 416 | sandmount () { # $1=type $2=source $3=target 417 | case "$1" in 418 | bind | bindro ) 419 | if [ -d "$2" ]; then 420 | mkmount "$2" 421 | elif [ ! -e "$3" ]; then 422 | mdir=`dirname "$2"` 423 | mkmount "$mdir" 424 | touch "$3" 425 | fi 426 | log ">>> mount --bind \"$2\" \"$3\"" "verb" 427 | mount --bind "$2" "$3" 428 | merr1=$? 429 | if [ "$2" != "/dev/random" ] && [ "$2" != "/dev/urandom" ]; then 430 | # remount 431 | if [ "$1" = "bindro" ]; then 432 | if [ "$2" = "/tmp" ]; then 433 | log "sandfox: Warning: You are mounting /tmp read-only - your programs" 434 | log " may not work properly in this sandbox" 435 | fi 436 | mopt="remount,bind,noatime,nosuid,ro" 437 | else 438 | mopt="remount,bind,noatime,nosuid" 439 | fi 440 | log ">>> mount -o $mopt \"$3\"" "verb" 441 | mount -o $mopt "$3" 442 | merr2=$? 443 | else 444 | # don't remount /dev/random - causes hang 445 | merr2=0 446 | if [ "$1" = "bindro" ]; then 447 | log "sandfox: Warning: $2 cannot be mounted ro - mounted rw" 448 | fi 449 | fi 450 | test=`mount | grep " on $3 type "` 451 | if [ "$test" = "" ] || (( merr1 + merr2 != 0 )); then 452 | log "sandfox: Error: $1 mount failed on $3" "quiet" 453 | if (( newsand == 1 )); then 454 | rmbox "$sand" 455 | fi 456 | exit 4 457 | fi 458 | ;; 459 | tmpfs ) 460 | mkmount "$2" 461 | if [ -d "$3" ]; then 462 | log ">>> mount -t tmpfs -o noatime,nosuid,size=$tmpfslimit tmpfs \"$3\"" "verb" 463 | mount -t tmpfs -o noatime,nosuid,size=$tmpfslimit tmpfs "$3" 464 | merr1=$? 465 | test=`mount | grep "^tmpfs on $3 type tmpfs"` 466 | if [ "$test" = "" ] || (( merr1 != 0 )); then 467 | log "sandfox: Error: tmpfs mount failed on $3" "quiet" 468 | if (( newsand == 1 )); then 469 | rmbox "$sand" 470 | fi 471 | exit 4 472 | fi 473 | else 474 | log "sandfox: Warning: Could not hide $2" 475 | fi 476 | ;; 477 | esac 478 | } 479 | 480 | boxstatus () { # $1 =box name OR "" for all 481 | if [ "$1" = "" ]; then 482 | boxes=`find $mnt -maxdepth 1 -mindepth 1 -type d 2> /dev/null` 483 | else 484 | boxes="$1" 485 | fi 486 | IFS=$'\n' 487 | log 488 | if [ "$boxes" = "" ]; then 489 | log " No sandboxes exist" 490 | else 491 | for b in $boxes ; do 492 | bname="$(basename "$b")" 493 | testdaemons=`ps -eo user,cmd | grep -v -e "grep" -e " /bin/su " | grep -c "sandfox .*--daemon.*$eventsfolder/$bname[[:blank:]]*$"` 494 | testfolders=`find "$b" -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort` 495 | testfolders="${testfolders//$IFS/ }" 496 | testmounts=`mount | grep -c " on $b/"` 497 | if [ "$testfolders" != "" ] || [ "$testdaemons" != "" ] || (( testmounts > 0 )); then 498 | makemsg=" (remake this sandbox to use it)" 499 | if (( testdaemons < 1 )) || [ ! -d "$eventsfolder/$bname" ]; then 500 | testdaemons="disabled$makemsg" 501 | makemsg="" 502 | else 503 | testuser=`ps -eo "%U %a" | grep -v -e "grep" -e " /bin/su " \ 504 | | grep -m 1 "sandfox .*--daemon.*$eventsfolder/$bname[[:blank:]]*$" \ 505 | | sed 's/\([a-zA-Z0-9]*\) .*/\1/'` 506 | testdaemons="running ($testuser)" 507 | fi 508 | if (( testmounts < 1 )); then 509 | testmounts="none$makemsg" 510 | makemsg="" 511 | else 512 | testmounts="$testmounts $mnt/$bname/" 513 | fi 514 | if [ testfolders = "" ]; then 515 | testfolders="none$makemsg" 516 | fi 517 | log "Sandbox: $bname" 518 | log " Daemon: $testdaemons" 519 | log " Mounts: $testmounts" 520 | log " Root Dirs: $testfolders" 521 | log 522 | fi 523 | done 524 | fi 525 | IFS=" " 526 | } 527 | 528 | mkprofiles () { 529 | # profile folder 530 | if [ "$profolder" = "" ]; then 531 | profolder="$defaultprofolder" 532 | fi 533 | mkdir -p "$profolder" 534 | if [ ! -d "$profolder" ]; then 535 | log "sandfox: Error: Could not create profile folder $profolder" "quiet" 536 | exit 3 537 | fi 538 | if [ ! -e "$profolder/default.profile" ]; then 539 | cat << EOF > "$profolder/default.profile" 540 | # Sandfox Default Profile 541 | # 542 | # WARNING: This default profile is loaded for all sandboxes and should only 543 | # contain the minimum folders required by all apps. If you do not at 544 | # least bind /bin /lib and /etc then the chroot command may not succeed. 545 | # 546 | # For instructions consult http://igurublog.wordpress.com/downloads/script-sandfox/ 547 | # OPTION 548 | # or 549 | # OPTION=VALUE (Do not use quotes) 550 | # 551 | # To include another profile in this profile: 552 | # profile=PROFILENAME 553 | 554 | 555 | # root folders and files 556 | bindro=/bin # required by chroot su - do not remove 557 | bindro=/etc # required by chroot su - do not remove 558 | bindro=/lib # required by chroot su - do not remove 559 | 560 | 561 | # recommended to keep apps happy 562 | bind=/dev/null 563 | bind=/dev/urandom 564 | bind=/dev/random 565 | bind=/dev/nvidia0 566 | bind=/dev/nvidiactl 567 | bindro=/lib32 568 | bindro=/lib64 569 | bindro=/opt/lib32 570 | bind=/tmp 571 | bindro=/usr 572 | bindro=/var/lib 573 | hide=/var/lib/mlocate # security 574 | 575 | 576 | # home folders and files 577 | # probably better to bind most home folders and files in another profile 578 | copy=/home/\$user/.bashrc # provides a disposable copy 579 | copy=/home/\$user/.bash_profile # provides a disposable copy 580 | 581 | 582 | # other folders and files 583 | # probably better to put these in another profile 584 | 585 | 586 | 587 | # Lockdown X Access (experimental) 588 | # These hides, disabled by default, MAY HELP to lockdown X access - for 589 | # example to discourage sandboxed apps from taking screen snapshots or 590 | # doing keylogging. If you enable these, be sure to close all sandboxes 591 | # before updating your system. Your package manager won't be able to 592 | # update these files while they are mounted in a sandbox. 593 | # 594 | # hide=/usr/bin/import 595 | # hide=/usr/bin/xauth 596 | # hide=/usr/bin/xev 597 | # hide=/usr/bin/xhost 598 | # hide=/usr/bin/xwd 599 | # hide=/usr/bin/xscreensaver 600 | # hide=/usr/bin/xscreensaver-command 601 | # hide=/usr/bin/xscreensaver-demo 602 | # hide=/usr/bin/xscreensaver-getimage 603 | # hide=/usr/bin/xscreensaver-getimage-file 604 | # hide=/usr/bin/xscreensaver-getimage-video 605 | # hide=/usr/bin/Xorg 606 | # hide=/etc/X11 607 | # hide=/usr/lib/X11 608 | 609 | 610 | EOF 611 | fi 612 | if [ ! -e "$profolder/firefox.profile" ]; then 613 | cat << EOF > "$profolder/firefox.profile" 614 | # Sandfox Firefox Profile 615 | # 616 | # Note that default.profile is always loaded in addition to other profiles 617 | # 618 | # For instructions consult http://igurublog.wordpress.com/downloads/script-sandfox/ 619 | # OPTION 620 | # or 621 | # OPTION=VALUE (Do not use quotes) 622 | # 623 | # To include another profile in this profile: 624 | # profile=PROFILENAME 625 | 626 | 627 | # root folders and files required by firefox 628 | bindro=/bin 629 | bindro=/opt/firefox # sometimes firefox is installed here 630 | bind=/dev/null 631 | bind=/dev/urandom # used by Firefox for security purposes 632 | bind=/dev/random # used by Firefox for printing 633 | bind=/dev/nvidia0 634 | bind=/dev/nvidiactl 635 | bindro=/etc 636 | bindro=/lib 637 | bindro=/lib32 638 | bindro=/lib64 639 | bindro=/opt/lib32 640 | bind=/tmp 641 | bindro=/usr 642 | bindro=/var/lib 643 | hide=/var/lib/mlocate 644 | bindro=/run/resolvconf # used by Firefox for DNS support 645 | 646 | # required by alsa for Flash sound 647 | bindro=/dev/snd 648 | 649 | # required by Java 650 | bindro=/opt/java 651 | bindro=/proc 652 | 653 | # required by Cups printing in Firefox 654 | bind=/var/cache/cups # Firefox starts faster 655 | bind=/var/cache/fontconfig # Firefox starts faster 656 | bind=/var/run # Firefox shows Cups printers 657 | 658 | # home folders and files 659 | # You may need to add additional binds to your home folders and files in order 660 | # for every aspect of Firefox to work as you want. Or you can share your 661 | # entire /home/\$user folder (this would reduce security) 662 | bind=/home/\$user/.mozilla 663 | bind=/home/\$user/.esd_auth 664 | bind=/home/\$user/.java 665 | bindro=/home/\$user/.asoundrc 666 | 667 | # Needed for KDE and Gnome themes in Firefox (may be incomplete for gnome) 668 | # To find out what other binds you may need, run 'env' in a shell as user 669 | # and examine the values of GTK2_RC_FILES and GTK_RC_FILES and XCURSOR_THEME 670 | # Note: The bind for kdeglobals below is a limited privacy risk, as KDE4 stores 671 | # recent file and folder names in this file. You can clean this file with 672 | # kscrubber: http://igurublog.wordpress.com/downloads/script-kscrubber/ 673 | # or don't bind it, but your theme may not work in Firefox 674 | bind=/home/\$user/.config/gtk-2.0 675 | bindro=/home/\$user/.fontconfig 676 | bindro=/home/\$user/.fonts 677 | bind=/home/\$user/.gtkrc-2.0 678 | bind=/home/\$user/.gtkrc-2.0-kde4 679 | bind=/home/\$user/.kde/share/config/gtkrc 680 | bind=/home/\$user/.kde/share/config/gtkrc-2.0 681 | bindro=/home/\$user/.kde/share/config/kdeglobals 682 | bind=/home/\$user/.kde4/share/config/gtkrc 683 | bind=/home/\$user/.kde4/share/config/gtkrc-2.0 684 | bindro=/home/\$user/.kde4/share/config/kdeglobals 685 | bindro=/home/\$user/.gtkrc-2.0-kde 686 | bind=/home/\$user/.kde3/share/config/gtkrc 687 | bind=/home/\$user/.kde3/share/config/gtkrc-2.0 688 | bindro=/home/\$user/.kde3/share/config/kdeglobals 689 | bindro=/home/\$user/.Xdefaults # for cursor theme 690 | bindro=/home/\$user/.Xauthority 691 | #bindro=/etc/gtk-2.0/gtkrc # used but already binded all of /etc 692 | 693 | 694 | # Required by flash player for persisent LSOs 695 | # Hide will store the cookies in ram and destroy them on exit. If you need 696 | # LSOs to be permanent, use bind= instead. 697 | # http://www.wired.com/epicenter/2009/08/you-deleted-your-cookies-think-again/ 698 | hide=/home/\$user/.adobe # creates a dummy folder 699 | hide=/home/\$user/.macromedia # creates a dummy folder 700 | 701 | 702 | # other folders and files 703 | # You may want to bind your Downloads or other data folders below so you 704 | # can easily save and upload files from within Firefox. 705 | 706 | EOF 707 | fi 708 | if [ ! -e "$profolder/skype.profile" ]; then 709 | cat << EOF > "$profolder/skype.profile" 710 | # Sandfox Skype Profile 711 | # 712 | # Note that default.profile is always loaded in addition to other profiles 713 | # 714 | # For instructions consult http://igurublog.wordpress.com/downloads/script-sandfox/ 715 | # OPTION 716 | # or 717 | # OPTION=VALUE (Do not use quotes) 718 | # 719 | # To include another profile in this profile: 720 | # profile=PROFILENAME 721 | 722 | # Set this to your Skype video device 723 | # Note: /dev/video probably won't work 724 | bind=/dev/video0 725 | 726 | bind=/dev/shm 727 | bind=/dev/snd 728 | bind=/dev/nvidia0 729 | bind=/dev/nvidiactl 730 | # bind=/sys/devices/system/cpu # ??? 731 | # bindro=/etc/pulse/client.conf # only needed if /etc not bound 732 | bindro=/proc/interrupts 733 | bindro=/var/cache/libx11/compose 734 | bind=/tmp 735 | bindro=/usr 736 | bind=/usr/share/skype # Gentoo users may need to disable this bind 737 | bind=/opt/skype 738 | 739 | # Following only needed if all of /tmp not bound above 740 | # copy=/tmp/.ICE-unix 741 | # copy=/tmp/.X11-unix/X0 742 | # bind=/tmp/pulse-*/native 743 | 744 | # Following only needed if all of /usr not bound above 745 | # copy=/usr/bin/skype 746 | # bindro=/usr/lib/qt4/plugins/iconengines 747 | # bindro=/usr/lib/qt4/plugins/imageformats 748 | # bindro=/usr/lib/qt4/plugins/imageformats 749 | # bindro=/usr/lib/qt4/plugins/inputmethods 750 | # bindro=/usr/share/X11/locale 751 | # bindro=/usr/share/icons 752 | # bindro=/usr/share/fonts 753 | 754 | bind=/home/\$user/.Skype 755 | bindro=/home/\$user/.ICEauthority 756 | bindro=/home/\$user/.Xauthority 757 | bindro=/home/\$user/.config/Trolltech.conf 758 | bindro=/home/\$user/.fontconfig 759 | bindro=/home/\$user/.asoundrc 760 | 761 | EOF 762 | fi 763 | if [ ! -e "$profolder/google-earth.profile" ]; then 764 | cat << EOF > "$profolder/google-earth.profile" 765 | # Sandfox Google-Earth Profile 766 | # 767 | # Note that default.profile is always loaded in addition to other profiles 768 | # 769 | # For instructions consult http://igurublog.wordpress.com/downloads/script-sandfox/ 770 | # OPTION 771 | # or 772 | # OPTION=VALUE (Do not use quotes) 773 | # 774 | # To include another profile in this profile: 775 | # profile=PROFILENAME 776 | 777 | 778 | # root folders and files 779 | bindro=/bin 780 | bind=/dev/null 781 | bind=/dev/urandom 782 | bind=/dev/random 783 | bind=/dev/nvidia0 784 | bind=/dev/nvidiactl 785 | bindro=/etc 786 | bindro=/lib 787 | bindro=/lib32 788 | bindro=/lib64 789 | bindro=/opt/lib32 790 | bind=/tmp 791 | bindro=/usr 792 | bindro=/var/lib 793 | hide=/var/lib/mlocate 794 | bindro=/opt/google/earth 795 | bindro=/opt/google-earth 796 | 797 | # required by Cups printing 798 | bind=/var/cache/cups 799 | bind=/var/cache/fontconfig 800 | bind=/var/run 801 | 802 | # home folders and files 803 | # You may need to add additional binds to your home folders and files in order 804 | # for every aspect of Google-Earth to work as you want. Or you can share your 805 | # entire /home/\$user folder (this would reduce security) 806 | bind=/home/\$user/.googleearth 807 | bind=/home/\$user/.config/Google 808 | bind=/home/\$user/.esd_auth 809 | bindro=/home/\$user/.config/Trolltech.conf 810 | 811 | # Themes 812 | bindro=/home/\$user/.Xdefaults 813 | bindro=/home/\$user/.Xauthority 814 | bindro=/home/\$user/.fontconfig 815 | bindro=/home/\$user/.fonts 816 | 817 | # other folders and files 818 | # You may want to bind your Downloads or other data folders below so you 819 | # can easily save and upload files from within Google-Earth. 820 | 821 | 822 | EOF 823 | fi 824 | if [ ! -e "$profolder/default.profile" ] || \ 825 | [ ! -e "$profolder/firefox.profile" ] || \ 826 | [ ! -e "$profolder/google-earth.profile" ] || \ 827 | [ ! -e "$profolder/skype.profile" ]; then 828 | log "sandfox: Error: Could not create default profiles in $profolder" "quiet" 829 | exit 3 830 | fi 831 | } 832 | 833 | 834 | ###################################################################################### 835 | # pre-init 836 | defaultprofolder="/etc/sandfox" 837 | # BE CAREFUL if you change $mnt - folder will be removed 838 | mnt="/mnt/sandfox" 839 | # eventsfolder cannot contain spaces and must be a bind 840 | eventsfolder="/tmp/sandfox-events" 841 | # maximum size of copy/hide folders 842 | tmpfslimit="100M" 843 | index=0 844 | bindscnt=0 845 | bindroscnt=0 846 | hidescnt=0 847 | copyscnt=0 848 | watchscnt=0 849 | closecnt=0 850 | prof[0]="default" 851 | profcnt=1 852 | profolder="" 853 | sandbox="" 854 | logfile="" 855 | logcl="$0 $*" 856 | curprofile="commandline" 857 | 858 | # find chroot 859 | wchroot=`which chroot` 860 | if [ "$wchroot" = "" ]; then 861 | if [ -e /usr/sbin/chroot ]; then 862 | wchroot=/usr/sbin/chroot 863 | elif [ -e /sbin/chroot ]; then 864 | wchroot=/sbin/chroot 865 | else 866 | wchroot=chroot 867 | fi 868 | fi 869 | 870 | # parse command line 871 | if [ "$1" = "" ]; then 872 | help 873 | exit 874 | fi 875 | while [ "$1" != "" ]; do 876 | if [ "${1:0:1}" = "-" ]; then 877 | o2=${1#*=} 878 | if [ "$1" != "$o2" ]; then 879 | # split = into two opts 880 | o1=${1%%=*} 881 | noshift=1 882 | else 883 | o1="$1" 884 | o2="$2" 885 | noshift=0 886 | fi 887 | processopt "$o1" "$o2" 888 | if [ "$?" = "2" ] && (( noshift == 0 )); then 889 | shift 890 | fi 891 | else 892 | bcmd="$*" 893 | bprog="${bcmd%% *}" 894 | bprog="$(basename $bprog)" 895 | if [ "$bprog" = "" ]; then 896 | log "sandfox: Error: Could not determine sandbox program" "quiet" 897 | exit 1 898 | fi 899 | break 900 | fi 901 | shift 902 | done 903 | 904 | # daemon mode 905 | # Note: Daemon mode is run internally as non-root user by sandfox to start 906 | # an events monitor which starts programs in the sandbox for the user 907 | # Daemon mode is not intended for direct use by the user 908 | if (( optdaemon == 1 )); then 909 | if (( watchscnt < 1 )); then 910 | log "sandfox-daemon: Error: Invalid daemon call - no watches" "quiet" 911 | exit 9 912 | fi 913 | watchx=0 914 | watchlist="" 915 | while (( watchx < watchscnt )); do 916 | watchlist="$watchlist \"${watchs[$watchx]}\"" 917 | (( watchx += 1 )) 918 | done 919 | 920 | # start watching 921 | user=`whoami` 922 | IFS=$'\n' 923 | while [ 1 ]; do 924 | log ">>> inotifywait -eq modify $watchlist" "verb" 925 | fnotify=`eval /usr/bin/inotifywait -q -e modify -e moved_to -e create $watchlist` 926 | if [ "$?" != "0" ]; then 927 | log "Quitting - watch stopped" 928 | exit 0 929 | fi 930 | # watch folders still exist? 931 | watchx=0 932 | while (( watchx < watchscnt )); do 933 | if [ ! -d "${watchs[$watchx]}" ]; then 934 | log "Quitting - ${watchs[$watchx]} deleted" 935 | exit 0 936 | fi 937 | (( watchx += 1 )) 938 | done 939 | # run 940 | f1=`echo "$fnotify" | grep -e " MODIFY " -e " CREATE " -e " MOVED_TO "` 941 | f1="${f1/ CREATE / MODIFY }" 942 | f1="${f1/ MOVED_TO / MODIFY }" 943 | if [ "$f1" != "" ]; then 944 | for fx in $f1 ; do 945 | fdir=${fx%% MODIFY *} 946 | f="$fdir${fx#* MODIFY }" 947 | ftest1=`basename "$f"` 948 | ftest2=`basename "$f" "desktop"` 949 | if [ "$ftest1" != "$ftest2" ]; then 950 | desktop=1 951 | else 952 | desktop=0 953 | fi 954 | if [ -f "$f" ] && [ -O "$f" ]; then 955 | if [ -x "$f" ] && (( desktop == 0)); then 956 | log "Executing $f..." 957 | $f & 958 | log "Deleting $f..." "verb" 959 | ( sleep 5 && rm -f "$f" ) & 960 | elif (( desktop == 1 )); then 961 | wcmd=`cat "$f" | grep -m 1 "^Exec="` 962 | if [ "$wcmd" != "" ]; then 963 | wcmd="${wcmd:5}" 964 | if [ "$wcmd" != "" ]; then 965 | log "Executing $wcmd ($f)..." 966 | eval $wcmd & 967 | log "Deleting $f..." "verb" 968 | ( sleep 5 && rm -f "$f" ) & 969 | else 970 | log "Could not execute $f" 971 | fi 972 | fi 973 | fi 974 | fi 975 | done 976 | fi 977 | done 978 | exit 12 979 | fi 980 | 981 | # determine sandbox user 982 | runuser=`whoami` 983 | if [ "$user" = "" ]; then 984 | if [ "$runuser" = "root" ]; then 985 | # based on env 986 | if [ "$SUDO_USER$LOGNAME$USER" != "" ]; then 987 | for u in $SUDO_USER $LOGNAME $USER ; do 988 | if [ "$u" != "root" ] && [ "$u" != "" ] && [ -e "/home/$u" ]; then 989 | user="$u" 990 | break 991 | fi 992 | done 993 | fi 994 | # based on Xauthority 995 | if [ "$user" = "" ] && [ "$XAUTHORITY" != "" ]; then 996 | user=`echo "$XAUTHORITY" | grep "^\/home\/.*\/\.Xauthority$" \ 997 | | sed 's/\/home\/\(.*\)\/.*/\1/'` 998 | if [ "$user" = "root" ]; then 999 | user="" 1000 | fi 1001 | fi 1002 | # based on /home and ps 1003 | if [ "$user" = "" ]; then 1004 | IFS=" " 1005 | ucnt=0 1006 | keepu="" 1007 | for d in /home/* ; do 1008 | u=`basename $d` 1009 | if [ "$u" != "" ] && [ "$u" != "/home/*" ]; then 1010 | test=`ps h -u $u -o "%U %c" 2> /dev/null` 1011 | if [ "$test" != "" ]; then 1012 | keepu="$u" 1013 | (( ucnt += 1 )) 1014 | fi 1015 | fi 1016 | done 1017 | if (( ucnt == 1 )) && [ "$keepu" != "root" ]; then 1018 | user="$keepu" 1019 | fi 1020 | fi 1021 | # based on pwd 1022 | if [ "$user" = "" ]; then 1023 | if [ "${PWD:0:6}" = "/home/" ]; then 1024 | u=`echo "$PWD" | sed 's/^\/home\/\([a-z0-9]*\).*/\1/'` 1025 | if [ "$u" != "" ] && [ "$u" != "root" ] && [ -e "/home/$u" ] ; then 1026 | user="$u" 1027 | fi 1028 | fi 1029 | fi 1030 | else 1031 | user="$runuser" 1032 | fi 1033 | fi 1034 | if [ "$user" = "root" ]; then 1035 | log "sandfox: Warning: Running root in the sandbox is not recommended!" "quiet" 1036 | elif [ "$user" = "" ]; then 1037 | log "sandfox: Error: Could not determine sandbox user" "quiet" 1038 | log " Please specify --user USERNAME" "quiet" 1039 | exit 2 1040 | fi 1041 | 1042 | # close 1043 | if (( optcloseall + closecnt != 0 )); then 1044 | if [ "$runuser" != "root" ]; then 1045 | log "sandfox: Error: Closing a sandbox requires root" "quiet" 1046 | exit 2 1047 | fi 1048 | if (( optcloseall == 1 )); then 1049 | if [ "$eventsfolder" != "" ]; then 1050 | log ">>> rm -rf $eventsfolder/*" "verb" 1051 | rm -rf $eventsfolder/* # this also stops daemons 1052 | sync 1053 | mkdir -p "$eventsfolder/tmp" 1054 | chmod ugo+rwx,+t "$eventsfolder/tmp" 2> /dev/null 1055 | fi 1056 | rmbox "$mnt" 1057 | else 1058 | closex=0 1059 | while (( closex < closecnt )); do 1060 | c="${closename[$closex]}" 1061 | # sandbox exists? 1062 | testdaemons=`ps -eo user,cmd | grep -v "grep" | grep "sandfox .*--daemon.*$eventsfolder/$c[[:blank:]]*$"` 1063 | testmounts=`mount | grep " on $mnt/$c " | wc -l` 1064 | if [ -e "$mnt/$c" ] || [ "$testdaemons" != "" ] || (( testmounts > 0 )); then 1065 | if [ "$eventsfolder" != "" ]; then 1066 | rm -rf "$eventsfolder/$c" 1067 | fi 1068 | rmbox "$mnt/$c" 1069 | else 1070 | log "sandfox: Warning: No such sandbox \"$c\"" "quiet" 1071 | fi 1072 | (( closex += 1 )) 1073 | done 1074 | fi 1075 | fi 1076 | 1077 | # assume make 1078 | if (( bindscnt + bindroscnt + copyscnt + hidescnt != 0 )) || (( profcnt > 1 )); then 1079 | optmake=1 1080 | elif [ "$sandbox" != "" ] && [ "$bcmd" = "" ]; then 1081 | optmake=1 1082 | fi 1083 | 1084 | # count usable daemons and assume make 1085 | if (( optmake == 0 )) && [ "$bcmd" != "" ]; then 1086 | if [ "$sandbox" = "" ]; then 1087 | daemoncnt=`ps -u $user -o "%U %a" | grep -v "grep" | grep -c " .*sandfox .*--daemon"` 1088 | else 1089 | daemoncnt=`ps -u $user -o "%U %a" | grep -v "grep" | grep -c "sandfox .*--daemon.*/$sandbox[[:blank:]]*$"` 1090 | fi 1091 | if (( daemoncnt == 0 )); then 1092 | log "There are no usable sandbox daemons running for $user - make has been enabled" 1093 | optmake=1 1094 | fi 1095 | fi 1096 | 1097 | # need root? 1098 | if [ "$runuser" != "root" ] && (( optmake + optcloseall + closecnt + optshell != 0 )); then 1099 | log "sandfox: Error: action requires root; run with sudo or --help for info" "quiet" 1100 | exit 2 1101 | fi 1102 | 1103 | # SECTION BELOW IS ROOT-ONLY 1104 | if (( optmake == 1 )) && [ "$runuser" = "root" ]; then 1105 | # create default profiles 1106 | mkprofiles 1107 | 1108 | # load profiles 1109 | profidx=0 1110 | loadedprofcnt=0 1111 | if [ "$bprog" != "" ] && [ -e "$profolder/$bprog.profile" ]; then 1112 | prof[$profcnt]="$bprog" 1113 | (( profcnt += 1 )) 1114 | fi 1115 | while (( profidx < profcnt )); do 1116 | # Note: prof[] may grow as profiles are read 1117 | loadprofile "${prof[$profidx]}" 1118 | (( profidx += 1 )) 1119 | done 1120 | 1121 | # sand 1122 | newsand=0 1123 | if [ "$sandbox" != "" ]; then 1124 | # sandbox exists? 1125 | filecount=`find "$mnt/$sandbox" -mindepth 1 2> /dev/null | wc -l` 1126 | testdaemons=`ps -eo user,cmd | grep -v "grep" | grep "sandfox .*--daemon.*/$sandbox[[:blank:]]*$"` 1127 | testmounts=`mount | grep " on $mnt/$sandbox" | wc -l` 1128 | if (( filecount > 0 )) || [ "$testdaemons" != "" ] || (( testmounts > 0 )); then 1129 | newsand=0 1130 | else 1131 | newsand=1 1132 | fi 1133 | sandname="$sandbox" 1134 | else 1135 | if [ "$bprog" = "" ]; then 1136 | p="${prof[1]}" 1137 | if [ "${p:0:1}" = "/" ]; then 1138 | p=`basename "$p" ".profile"` 1139 | fi 1140 | if [ "$p" != "" ]; then 1141 | sandname="$p" 1142 | else 1143 | sandname="default" 1144 | fi 1145 | else 1146 | sandname="$bprog" 1147 | fi 1148 | sandnametmp="$sandname" 1149 | while [ -e "$mnt/$sandname" ]; do 1150 | randhex4 1151 | sandname="$sandnametmp-$randhex" 1152 | done 1153 | newsand=1 1154 | fi 1155 | if (( newsand == 1 )); then 1156 | log "Creating new sandbox \"$sandname\"" 1157 | else 1158 | log 1159 | log "Updating sandbox $sandname" 1160 | fi 1161 | sand="$mnt/$sandname" 1162 | 1163 | # default folders 1164 | mkdir -p "$mnt" 1165 | chown root:root "$mnt" 1166 | chmod go+rx,go-w "$mnt" 1167 | mkdir "$sand" 1168 | chown root:root "$sand" 1169 | chmod go+rx,go-w "$sand" 1170 | if [ ! -d "$sand" ]; then 1171 | log "sandfox: Error: Could not create sand folder $sand" "quiet" 1172 | exit 3 1173 | fi 1174 | 1175 | # check for required binds 1176 | bindtmp=0 1177 | bindbin=0 1178 | bindetc=0 1179 | bindlib=0 1180 | bindusrlib=0 1181 | bindusrbin=0 1182 | binddev=0 1183 | bidx=0 1184 | while (( bidx < bindscnt )); do 1185 | case "${binds[$bidx]}" in 1186 | /tmp ) 1187 | bindtmp=1 1188 | ;; 1189 | /dev ) 1190 | binddev=1 1191 | ;; 1192 | /bin ) 1193 | bindbin=1 1194 | ;; 1195 | /etc ) 1196 | bindetc=1 1197 | ;; 1198 | /lib ) 1199 | bindlib=1 1200 | ;; 1201 | /usr ) 1202 | bindusrbin=1 1203 | bindusrlib=1 1204 | ;; 1205 | /usr/bin ) 1206 | bindusrbin=1 1207 | ;; 1208 | /usr/lib ) 1209 | bindusrlib=1 1210 | ;; 1211 | esac 1212 | (( bidx += 1 )) 1213 | done 1214 | bidx=0 1215 | while (( bidx < bindroscnt )); do 1216 | case "${bindros[$bidx]}" in 1217 | /tmp ) 1218 | bindtmp=1 1219 | ;; 1220 | /dev ) 1221 | binddev=1 1222 | ;; 1223 | /bin ) 1224 | bindbin=1 1225 | ;; 1226 | /etc ) 1227 | bindetc=1 1228 | ;; 1229 | /lib ) 1230 | bindlib=1 1231 | ;; 1232 | /usr ) 1233 | bindusrbin=1 1234 | bindusrlib=1 1235 | ;; 1236 | /usr/bin ) 1237 | bindusrbin=1 1238 | ;; 1239 | /usr/lib ) 1240 | bindusrlib=1 1241 | ;; 1242 | esac 1243 | (( bidx += 1 )) 1244 | done 1245 | if (( bindtmp == 0 )); then 1246 | if [ "${eventsfolder:0:4}" = "/tmp" ]; then 1247 | binds[$bindscnt]="$eventsfolder" 1248 | (( bindscnt += 1 )) 1249 | fi 1250 | log "sandfox: Warning: Not binding /tmp may cause some programs to fail or hang" 1251 | fi 1252 | if (( binddev == 0 )); then 1253 | binds[$bindscnt]="/dev/null" 1254 | (( bindscnt += 1 )) 1255 | fi 1256 | if (( bindusrbin == 0 )); then 1257 | bindros[$bindroscnt]="/usr/bin/inotifywait" 1258 | (( bindroscnt += 1 )) 1259 | bindros[$bindroscnt]="/usr/bin/whoami" 1260 | (( bindroscnt += 1 )) 1261 | bindros[$bindroscnt]="/usr/bin/basename" 1262 | (( bindroscnt += 1 )) 1263 | fi 1264 | if (( bindusrlib == 0 )); then 1265 | f1=`find /usr/lib -maxdepth 1 -xtype f -name "libinotifytools*.so*" 2> /dev/null` 1266 | if [ "$f1" != "" ]; then 1267 | IFS=$'\n' 1268 | for f in $f1 ; do 1269 | bindros[$bindroscnt]="$f" 1270 | (( bindroscnt += 1 )) 1271 | done 1272 | IFS=" " 1273 | fi 1274 | fi 1275 | if (( bindbin + bindlib + bindetc != 3 )); then 1276 | log "sandfox: Warning: Not binding /bin /etc and /lib may not allow" 1277 | log " the chroot or su commands to run" 1278 | fi 1279 | if [ ! -e "/usr/bin/inotifywait" ]; then 1280 | log "sandfox: Error: /usr/bin/inotifywait not found" "quiet" 1281 | log " Arch use: pacman -S inotify-tools" "quiet" 1282 | log " Ubuntu use: apt-get install inotify-tools" "quiet" 1283 | exit 3 1284 | fi 1285 | 1286 | # binds 1287 | for b in bindro bind copy hide ; do 1288 | # step through list of binds to be processed 1289 | bidx=0 1290 | eval bcnt=$b\scnt 1291 | while (( bidx < bcnt )); do 1292 | eval curb=\"\${$b\s[$bidx]}\" # current bind item 1293 | curb=${curb//\$user/$user} 1294 | log "Processing $b $curb" "verb" 1295 | if [ -e "$curb" ] || [ "$b" = "hide" ]; then 1296 | # check for duplicates 1297 | dupefound=0 1298 | (( dupeidx = bidx - 1 )) 1299 | while (( dupeidx > -1 )); do 1300 | eval dupeb=\"\${$b\s[$dupeidx]}\" # possible duplicate item 1301 | dupeb=${dupeb//\$user/$user} 1302 | if [ "$dupeb" = "$curb" ]; then 1303 | dupefound=1 1304 | break 1305 | fi 1306 | (( dupeidx -= 1 )) 1307 | done 1308 | # process 1309 | if (( dupefound == 0 )); then 1310 | test=`mount | grep " $sand$curb "` 1311 | if [ "$test" != "" ]; then 1312 | log "$b $sand$curb: already mounted" "verb" 1313 | else 1314 | case "$b" in 1315 | bindro | bind ) 1316 | # create mount point and recursively copy permissions 1317 | # bind mount file or folder 1318 | sandmount $b "$curb" "$sand$curb" 1319 | ;; 1320 | copy | hide ) 1321 | if [ -d "$curb" ] || [ ! -e "$curb" ]; then 1322 | # folder copy/hide 1323 | # mount on tmpfs 1324 | sandmount tmpfs "$curb" "$sand$curb" 1325 | if [ -e "$curb" ]; then 1326 | chmod --reference="$curb" "$sand$curb" 2> /dev/null 1327 | chown --reference="$curb" "$sand$curb" 2> /dev/null 1328 | else 1329 | # non-existent hide permissions 1330 | chmod ugo+rwx "$sand$curb" 2> /dev/null 1331 | chown $user:$user "$sand$curb" 2> /dev/null 1332 | fi 1333 | if [ "$b" = "copy" ]; then 1334 | log ">>> cp -ax \"$curb/.\" \"$sand$curb/.\"" "verb" 1335 | cp -ax "$curb/." "$sand$curb/." 1336 | if [ "$?" != "0" ]; then 1337 | log "sandfox: Warning: cp reported an error copying $curb" "quiet" 1338 | fi 1339 | fi 1340 | else 1341 | # file copy/hide 1342 | if [ "$b" = "copy" ]; then 1343 | # copy 1344 | if [ ! -e "$sand$curb" ]; then 1345 | mdir=`dirname "$curb"` 1346 | mkmount "$mdir" 1347 | log ">>> cp -a \"$curb\" \"$sand$curb\"" "verb" 1348 | cp -a "$curb" "$sand$curb" 1349 | if [ "$?" != "0" ]; then 1350 | log "sandfox: Warning: cp reported an error copying $curb" "quiet" 1351 | fi 1352 | else 1353 | log "Cannot create copy of $curb" "verb" 1354 | log " because it already exists in sandbox" "verb" 1355 | fi 1356 | else 1357 | # hide 1358 | sandmount bind "/dev/null" "$sand$curb" 1359 | fi 1360 | fi 1361 | ;; 1362 | esac 1363 | fi 1364 | fi 1365 | fi 1366 | (( bidx += 1 )) 1367 | done 1368 | done 1369 | sync 1370 | 1371 | # daemon running for user? 1372 | test=`ps -u $user -o "%U %a" | grep -v "grep" \ 1373 | | grep " .*sandfox .*--daemon .*$eventsfolder/$sandname[[:blank:]]*$"` 1374 | if [ "$test" = "" ]; then 1375 | # start daemon 1376 | if [ "$logfile" != "" ]; then 1377 | dlog="--logfile $logfile" 1378 | else 1379 | dlog="" 1380 | fi 1381 | if (( optverbose == 1 )); then 1382 | verb="--verbose" 1383 | else 1384 | verb="" 1385 | fi 1386 | mkdir -p "$eventsfolder" 1387 | chown root:root "$eventsfolder" 2> /dev/null 1388 | chmod ugo+rwx,+t "$eventsfolder" 2> /dev/null 1389 | if [ ! -d "$eventsfolder" ]; then 1390 | log "sandfox: Error: Could not create events folder $eventsfolder" "quiet" 1391 | exit 3 1392 | fi 1393 | mkdir -p "$eventsfolder/tmp" 1394 | chmod ugo+rwx,+t "$eventsfolder/tmp" 2> /dev/null 1395 | cp "$0" "$eventsfolder/tmp/sandfox" 1396 | chmod ugo+rx,go-w "$eventsfolder/tmp/sandfox" 1397 | mkdir -p "$eventsfolder/$sandname" 1398 | chmod ugo+rwx,+t "$eventsfolder/$sandname" 1399 | log "Starting daemon as $user for sandbox \"$sandname\"..." "verb" 1400 | log ">>> $wchroot $sand /bin/su $user -c \"$eventsfolder/tmp/sandfox --daemon $dlog $verb --watch $eventsfolder/$sandname\"" "verb" 1401 | if (( optverbose == 1 )); then 1402 | $wchroot $sand /bin/su $user -c "$eventsfolder/tmp/sandfox --daemon $dlog $verb --watch $eventsfolder/$sandname" & 1403 | else 1404 | $wchroot $sand /bin/su $user -c "$eventsfolder/tmp/sandfox --daemon $dlog $verb --watch $eventsfolder/$sandname" 2> /dev/null > /dev/null & 1405 | fi 1406 | sleep .5 1407 | test=`ps -u $user -o "%U %a" | grep -v "grep" \ 1408 | | grep " .*sandfox .*--daemon .*$eventsfolder/$sandname[[:blank:]]*$"` 1409 | if [ "$test" = "" ]; then 1410 | log "sandfox: Warning: Could not start daemon - you may not be able" "quiet" 1411 | log " to run additional programs in this sandbox" "quiet" 1412 | fi 1413 | fi 1414 | fi 1415 | 1416 | # run command in sandbox 1417 | if [ "$bcmd" != "" ]; then 1418 | if [ "$sandname" = "" ]; then 1419 | # check/set sandbox name 1420 | if [ "$sandbox" != "" ]; then 1421 | sandname="$sandbox" 1422 | else 1423 | # find a sandbox daemon to run bcmd 1424 | IFS=" " 1425 | dtotal=0 1426 | dprefer="" 1427 | dgood="" 1428 | for d in $eventsfolder/* ; do 1429 | if [ "$d" != "$eventsfolder/*" ] && [ "$d" != "" ] && [ -d "$d" ] \ 1430 | && [ "$d" != "$eventsfolder/tmp" ] ; then 1431 | dname=`basename "$d"` 1432 | test=`ps -u $user -o "%U %a" | grep -v "grep" \ 1433 | | grep " .*sandfox .*--daemon .*$d[[:blank:]]*$"` 1434 | if [ "$test" != "" ]; then 1435 | examples="$examples sandfox --sandbox $dname $bcmd\n" 1436 | dgood="$dname" 1437 | if [ "$dname" = "$bprog" ]; then 1438 | dprefer="$dname" 1439 | fi 1440 | (( dtotal += 1 )) 1441 | fi 1442 | fi 1443 | done 1444 | if (( dtotal == 0 )); then 1445 | log "sandfox: Error: There is no open sandbox to run $bprog" "quiet" 1446 | exit 5 1447 | elif (( dtotal > 1 )); then 1448 | log "sandfox: Warning: There is more than one sandbox open" 1449 | log " To specify a sandbox:" 1450 | echo -e "$examples" 1451 | if [ "$dprefer" != "" ]; then 1452 | sandname="$dprefer" 1453 | else 1454 | sandname="$dgood" 1455 | fi 1456 | else 1457 | sandname="$dgood" 1458 | fi 1459 | fi 1460 | fi 1461 | 1462 | # Check if firefox already running 1463 | if [ "${bcmd%% *}" = "firefox" ]; then 1464 | testrunning=`ps -u $user -o "%U %a" | grep -v "grep" | grep -v "sandfox" \ 1465 | | grep -e " *${bcmd%% *}$" -e " *${bcmd%% *} "` 1466 | if [ "$testrunning" != "" ]; then 1467 | log "sandfox: Warning: An instance of ${bcmd%% *} is already running" 1468 | fi 1469 | fi 1470 | 1471 | if [ "$runuser" = "root" ]; then 1472 | # start directly 1473 | if (( optshell == 1 )) || [ "$bprog" = "bash" ]; then 1474 | log 1475 | if [ "$bprog" = "bash" ]; then 1476 | p="" 1477 | else 1478 | p=" running $bprog" 1479 | fi 1480 | log ">>> shell - you are $user$p in sandbox \"$sandname\" <<<" 1481 | log ">>> $wchroot $mnt/$sandname /bin/su $user -c \"$bcmd\"" "verb" 1482 | if [ "$SUDO_USER" != "" ]; then 1483 | ruser="$SUDO_USER" 1484 | else 1485 | ruser="ROOT" 1486 | fi 1487 | $wchroot $mnt/$sandname /bin/su $user -c "$bcmd" 1488 | log 1489 | log "<<< exit - you are $ruser out of the sandbox >>>" 1490 | else 1491 | log "Starting $bprog as $user in sandbox \"$sandname\"..." 1492 | log ">>> $wchroot $mnt/$sandname /bin/su $user -c \"$bcmd\" &" "verb" 1493 | if (( verbose == 1 )); then 1494 | $wchroot $mnt/$sandname /bin/su $user -c "$bcmd" & 1495 | else 1496 | $wchroot $mnt/$sandname /bin/su $user -c "$bcmd" 2> /dev/null > /dev/null & 1497 | fi 1498 | fi 1499 | else 1500 | log "Starting $bprog as $user in sandbox \"$sandname\"..." 1501 | # start via daemon 1502 | # get env of caller 1503 | e=`env | grep -v "'" | sed "s/\([A-Z_]*=\)\(.*\)/\1\\\'\2\\\'/"` 1504 | if [ "$e" != "" ]; then 1505 | e="env -i ${e//$'\n'/ }" 1506 | else 1507 | e="" 1508 | fi 1509 | # build start script 1510 | randhex4 1511 | cscript="$bprog-$randhex.sh" 1512 | while [ -e "$eventsfolder/tmp/$cscript" ]; do 1513 | randhex4 1514 | cscript="$bprog-$randhex.sh" 1515 | done 1516 | cat << EOF > "$eventsfolder/tmp/$cscript" 1517 | #!/bin/bash 1518 | # sandfox automatic start script 1519 | # It is safe to delete this file 1520 | 1521 | $e $bcmd & 1522 | EOF 1523 | chmod u+x,go-rwx "$eventsfolder/tmp/$cscript" 1524 | # move start script to events folder 1525 | mv -f "$eventsfolder/tmp/$cscript" "$eventsfolder/$sandname" 1526 | log "Wrote start script $cscript ($bcmd)" "verb" 1527 | fi 1528 | fi 1529 | 1530 | if (( optstatus == 1 )); then 1531 | boxstatus 1532 | fi 1533 | 1534 | exit 1535 | 1536 | # CHANGELOG: 1537 | # 1.1.4: chroot discovery 1538 | # added Firefox and Skype bindro=/home/\$user/.asoundrc 1539 | # 1.1.3: added bindro /run/resolvconf to default Firefox profile 1540 | # 1.1.2: accomodate change to remount bind usage 1541 | # accomodate change to mtab bind mounts showing type 1542 | # added /dev/nvidia0 & /dev/nvidiactl binds to default profiles 1543 | # added bindro=/opt/firefox to default firefox profile 1544 | # improved detection for 'firefox already running' warning 1545 | # 1.1.1: accomodate recent change to ps line endings 1546 | # 1.1.0: kills dbus-launch inside sandboxes before closing (lsof required) 1547 | # 1.0.10: use tmpfs instead of none for mount source (due to new util-linux) 1548 | # skype profile adds /opt/skype and disable note for Gentoo users 1549 | # 1.0.9: permissions on mnt folders 1550 | # removed uuidgen dependency 1551 | # determine sandbox user with Xauthority 1552 | # added default google-earth profile 1553 | # 1.0.8: modification of daemon detection for non-standard ps 1554 | # non-existent --sandbox triggers make 1555 | # corrected --status mount count 1556 | # 1.0.7: added /dev/video0 to skype profile (replaces /dev/video) 1557 | # added disabled Lockdown X Access section to default profile 1558 | # 1.0.6: added firefox bindro for ~/.Xauthority 1559 | # added warning if firefox already running 1560 | # 1.0.5: modification of daemon detection for non-standard ps 1561 | # 1.0.4: corrected detection of running daemon with --verbose and --logfile 1562 | # 1.0.3: corrected problems with sandboxes with similar names 1563 | # 1.0.2: hide non-existent folder corrected 1564 | # 1.0.0: handle /dev/urandom like /dev/random to prevent hangs 1565 | # 0.9.6: Changed tmpfslimit to 100M 1566 | # now allows successful bind=/dev/random for Firefox printing 1567 | # added user-contributed skype profile (experimental) 1568 | --------------------------------------------------------------------------------