├── AUTHORS.md ├── CMakeLists.txt ├── COPYING ├── HACKING.md ├── NEWS.md ├── README.md ├── THANKS.md ├── TODO.md ├── bin └── schroot │ ├── CMakeLists.txt │ ├── main.cc │ ├── main.h │ ├── options.cc │ ├── options.h │ └── schroot.cc ├── cmake ├── BoostChecks.cmake ├── CompilerChecks.cmake ├── GitRelease.cmake ├── GitReleasePolicy.cmake └── RegexChecks.cmake ├── config.h.cmake ├── contrib └── setup.d │ ├── 05customdir │ ├── 09fsck │ └── 10mount-ssh ├── doc ├── CMakeLists.txt ├── REQUIREMENTS ├── historical │ └── sbuild-chroot-helper.c ├── schroot-bin.dox.cmake └── schroot.dox.cmake ├── etc ├── CMakeLists.txt ├── bash_completion │ ├── CMakeLists.txt │ └── schroot ├── pam │ ├── CMakeLists.txt │ └── schroot ├── profile-templates │ ├── all │ │ ├── all │ │ │ ├── copyfiles │ │ │ ├── fstab │ │ │ └── nssdatabases │ │ ├── freebsd │ │ │ └── fstab │ │ ├── gnu │ │ │ └── fstab │ │ └── linux │ │ │ └── fstab │ ├── buildd │ │ ├── all │ │ │ ├── copyfiles │ │ │ └── nssdatabases │ │ ├── freebsd │ │ │ └── fstab │ │ └── linux │ │ │ └── fstab │ ├── default │ │ ├── all │ │ │ └── nssdatabases │ │ ├── freebsd │ │ │ └── fstab │ │ ├── gnu │ │ │ └── fstab │ │ └── linux │ │ │ └── fstab │ ├── desktop │ │ ├── all │ │ │ └── nssdatabases │ │ ├── freebsd │ │ │ └── fstab │ │ ├── gnu │ │ │ └── fstab │ │ └── linux │ │ │ └── fstab │ └── sbuild │ │ ├── freebsd │ │ └── fstab │ │ └── linux │ │ └── fstab ├── schroot.conf └── setup.d │ ├── 00check │ ├── 05btrfs │ ├── 05file │ ├── 05union │ ├── 10mount │ ├── 15binfmt │ ├── 15killprocs │ ├── 20copyfiles │ ├── 20nssdatabases │ ├── 50chrootname │ ├── 60unshare │ ├── 70services │ ├── CMakeLists.txt │ ├── common-config │ ├── common-data │ └── common-functions ├── lib ├── bin-common │ ├── CMakeLists.txt │ ├── main.cc │ ├── main.h │ ├── option-action.cc │ ├── option-action.h │ ├── options.cc │ ├── options.h │ └── run.h ├── schroot │ ├── CMakeLists.txt │ ├── auth │ │ ├── auth.cc │ │ ├── auth.h │ │ ├── deny.cc │ │ ├── deny.h │ │ ├── pam-conv-tty.cc │ │ ├── pam-conv-tty.h │ │ ├── pam-conv.cc │ │ ├── pam-conv.h │ │ ├── pam-message.cc │ │ ├── pam-message.h │ │ ├── pam.cc │ │ └── pam.h │ ├── chroot │ │ ├── chroot.cc │ │ ├── chroot.h │ │ ├── config.cc │ │ ├── config.h │ │ └── facet │ │ │ ├── block-device-base.cc │ │ │ ├── block-device-base.h │ │ │ ├── block-device.cc │ │ │ ├── block-device.h │ │ │ ├── btrfs-snapshot.cc │ │ │ ├── btrfs-snapshot.h │ │ │ ├── custom.cc │ │ │ ├── custom.h │ │ │ ├── directory-base.cc │ │ │ ├── directory-base.h │ │ │ ├── directory.cc │ │ │ ├── directory.h │ │ │ ├── facet.cc │ │ │ ├── facet.h │ │ │ ├── factory.cc │ │ │ ├── factory.h │ │ │ ├── file.cc │ │ │ ├── file.h │ │ │ ├── fsunion.cc │ │ │ ├── fsunion.h │ │ │ ├── loopback.cc │ │ │ ├── loopback.h │ │ │ ├── mountable.cc │ │ │ ├── mountable.h │ │ │ ├── personality.cc │ │ │ ├── personality.h │ │ │ ├── plain.cc │ │ │ ├── plain.h │ │ │ ├── session-clonable.cc │ │ │ ├── session-clonable.h │ │ │ ├── session-setup.cc │ │ │ ├── session-setup.h │ │ │ ├── session.cc │ │ │ ├── session.h │ │ │ ├── source-clonable.cc │ │ │ ├── source-clonable.h │ │ │ ├── source-setup.cc │ │ │ ├── source-setup.h │ │ │ ├── source.cc │ │ │ ├── source.h │ │ │ ├── storage.cc │ │ │ ├── storage.h │ │ │ ├── unshare.cc │ │ │ ├── unshare.h │ │ │ ├── userdata.cc │ │ │ └── userdata.h │ ├── config.h.cmake │ ├── ctty.cc │ ├── ctty.h │ ├── custom-error.h │ ├── environment.cc │ ├── environment.h │ ├── error.h │ ├── error.tcc │ ├── fdstream.h │ ├── feature.cc │ ├── feature.h │ ├── format-detail.cc │ ├── format-detail.h │ ├── i18n.h │ ├── keyfile-reader.cc │ ├── keyfile-reader.h │ ├── keyfile-writer.cc │ ├── keyfile-writer.h │ ├── keyfile.cc │ ├── keyfile.h │ ├── lock.cc │ ├── lock.h │ ├── log.cc │ ├── log.h │ ├── mntstream.cc │ ├── mntstream.h │ ├── nostream.cc │ ├── nostream.h │ ├── parse-error.h │ ├── parse-value.cc │ ├── parse-value.h │ ├── personality.cc │ ├── personality.h │ ├── regex.h │ ├── run-parts.cc │ ├── run-parts.h │ ├── schroot.pc.cmake │ ├── schroot.pc.in │ ├── session.cc │ ├── session.h │ ├── types.cc │ ├── types.h │ ├── util.cc │ └── util.h └── test │ ├── CMakeLists.txt │ └── testmain.cc ├── libexec ├── listmounts │ ├── CMakeLists.txt │ ├── listmounts.cc │ ├── main.cc │ ├── main.h │ ├── options.cc │ └── options.h └── mount │ ├── CMakeLists.txt │ ├── main.cc │ ├── main.h │ ├── mount.cc │ ├── options.cc │ └── options.h ├── man ├── CMakeLists.txt ├── add │ ├── addendum.template │ └── fr.add ├── authors.man ├── config.man.cmake ├── copyright.man ├── examples │ ├── conf-chroots.man │ ├── conf-userdata-env.man │ ├── conf-userdata.man │ ├── faq-git-clone.man │ ├── faq-rm-session-config.man │ ├── faq-rm-session-mounted-fs.man │ ├── faq-session-auto.man │ ├── faq-session-create1.man │ ├── faq-session-create2.man │ ├── faq-session-end1.man │ ├── faq-session-end2.man │ ├── faq-session-name.man │ ├── faq-session-run1.man │ ├── faq-session-run2.man │ ├── faq-session-run3.man │ ├── schroot-command.man │ ├── schroot-info.man │ ├── schroot-list.man │ ├── schroot-session-chrootinfo.man │ ├── schroot-session-create1.man │ ├── schroot-session-create2.man │ ├── schroot-session-createname.man │ ├── schroot-session-end.man │ ├── schroot-session-runcommand.man │ ├── schroot-session-runcommand1.man │ ├── schroot-session-sessioninfo.man │ └── schroot-userswitch.man ├── po │ ├── LINGUAS │ ├── de.po │ ├── fr.po │ └── schroot-man.pot ├── po4a.cfg ├── schroot-faq.7.man ├── schroot-script-config.5.man ├── schroot-setup.5.man ├── schroot.1.man └── schroot.conf.5.man ├── po ├── CMakeLists.txt ├── LINGUAS ├── POTFILES.in ├── cs.po ├── da.po ├── de.po ├── en.po ├── eu.po ├── fr.po ├── it.po ├── pt.po ├── schroot.pot ├── sv.po ├── vi.po └── zh_CN.po └── test ├── CMakeLists.txt ├── bin-common └── option-action.cc ├── config-directory-deprecated.ex ├── config-directory-fail.ex ├── config-directory-valid.ex ├── config.ex1 ├── config.ex2 ├── empty ├── experimental ├── file ├── sarge ├── sid └── woody ├── keyfile.ex1 ├── run-parts.ex1 ├── 10test1 ├── 20test2 └── 30test3 ├── run-parts.ex3 └── 50invalid ├── schroot ├── chroot │ ├── block-device.cc │ ├── btrfs-snapshot.cc │ ├── chroot.cc │ ├── chroot.h │ ├── config.cc │ ├── custom.cc │ ├── directory.cc │ ├── facet │ │ └── userdata.cc │ ├── file.cc │ ├── loopback.cc │ └── plain.cc ├── environment.cc ├── keyfile.cc ├── lock.cc ├── log.cc ├── nostream.cc ├── parse-value.cc ├── personality.cc ├── regex.cc ├── run-parts.cc └── util.cc └── setup-test-data /AUTHORS.md: -------------------------------------------------------------------------------- 1 | # Authors of schroot contributions 2 | 3 | The list of contributors, in alphabetical order, is as follows. The 4 | principal areas that each person contributed to are listed in addition. 5 | 6 | - Tim Abbott 7 | * schroot bash completion. 8 | - Andy Bailey 9 | * Boost 1.42 compatibility. 10 | - Andreas Bombe 11 | * Documentation improvements. 12 | - Kees Cook 13 | * `15killprocs` script to kill processes. 14 | * `schroot-mount` improvements. 15 | - Jan-Marek Glogowski 16 | * Union filesystem support. 17 | - Federico Di Gregorio 18 | *Init script improvements. 19 | - Aurelien Jarno 20 | * GNU/kFreeBSD and FreeBSD porting. 21 | - Roger Leigh 22 | * Original architecture and design. 23 | * Main programming. 24 | * Testsuite. 25 | * Documentation. 26 | - Nathaniel W. Turner 27 | * Addition of correct `SIGINT` handling when running setup 28 | scripts. 29 | -------------------------------------------------------------------------------- /THANKS.md: -------------------------------------------------------------------------------- 1 | # Thank you 2 | 3 | `schroot` was originally written by Roger Leigh 4 | . It would not be what it is today without the 5 | invaluable help of these people: 6 | 7 | - Andreas Bombe 8 | - Raphaël Hertzog 9 | - Steve Langasek 10 | - Martin Michlmayr 11 | - Lucas Nussbaum 12 | - Adeodato Simó 13 | 14 | I would like to thank all of the above for their many suggestions, 15 | feature requests and bug reports. Without their destruction testing 16 | and help, `schroot` would not have been pushed as far as it has. I 17 | would also like to thanks the following people for their specific 18 | contributions: 19 | 20 | - Zach Carter 21 | * Packaging for Fedora. 22 | * Bugfixes and patches. 23 | - Ben Hutchings 24 | * Help with many C++ problems, especially the intricacies of 25 | templates and other obscure and annoying language features. 26 | - Aurelien Jarno 27 | * GNU/kFreeBSD porting. 28 | - Simon Richter 29 | * Help with PAM session handling. 30 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # To Do List 2 | 3 | Most new items are now marked with `@todo` in the source code and 4 | listed in the Doxygen-generated documentation in 5 | `doc/schroot/html/todo.html`. Note that the list is also somewhat 6 | dated, with some items having been mostly completed, and others 7 | obsoleted in the interim by architectural changes. 8 | 9 | 10 | ## Planned changes 11 | 12 | - Add API to run multiple commands to replace `auth::run()`. 13 | 14 | - Add extra file permissions checking. 15 | 16 | Both of these changes are to run-parts, to ensure that shell scripts 17 | are owned by root and not world writable (as for config files). And 18 | also add the same permissions check to `script-config` files. 19 | 20 | - Generalise permissions checking. 21 | 22 | Create a standard function which can use either `stat`, `fstat` or 23 | `lstat` and test for particular permissions. 24 | 25 | - `SCHROOT_CONF` error messages must also mention `chroot.d`. 26 | 27 | - Document that database files on the root filesystem must not be 28 | directly shared inside the chroot. 29 | 30 | Setup scripts such as `20nssdatabases` can blank them out. 31 | 32 | - Document all environment variables in schroot-setup(5). 33 | 34 | ## Potential changes 35 | 36 | - Add tests for: 37 | * `Auth`. 38 | * `AuthConv`. 39 | * `AuthConvTty`. 40 | * `AuthMessage`. 41 | * `Session`. 42 | * `schroot::Options`. 43 | 44 | None of these are urgent and/or are difficult to test in an automated 45 | fashion. `expect` might be useful for testing the PAM wrappers. 46 | 47 | - Line reporting while parsing config files misses file name. 48 | 49 | `log_warning()` is used, because we don't throw an exception. The 50 | code has no knowledge of the file name, so can't report it. 51 | Outright errors throw, and the handler adds the needed context. 52 | 53 | - Unify `fork`/`exec` code into a `spawn` function. 54 | 55 | - Tests for chroots: 56 | 57 | * -source chroots. 58 | 59 | - logging should allow customisation of log level. 60 | 61 | * See end of Debian Bug #279408. 62 | 63 | * log functions should have a severity (to complement existing I/W/E types). 64 | 65 | Similar to debug level, but for normal messages 66 | e.g. quiet/normal/verbose/extra verbose. 67 | 68 | - Add a `read-only` mount option for `union` underlay (both for 69 | devices and bind mounts). 70 | 71 | - Union mounts should allow overlay/underlay to be user-specified? 72 | 73 | Or only allow underlay to be specified (but it's already specified 74 | in the chroot definition, so don't allow?). Note: Currently user 75 | settings are automatically overridden. 76 | 77 | - Add directories under /var to man pages. 78 | 79 | - Add checks for unsupported features in setup scripts. 80 | 81 | - Define `operator &=` and `|=` for enum types defining `|` and `&` 82 | operators. 83 | 84 | - Header include order: `chroot-facet` depends upon `schroot-chroot` 85 | being included first. Try to break this dependency. 86 | 87 | - `--end-session --force` should forcibly end "broken" sessions by 88 | manually umounting and purging mount and session directories and 89 | metadata. 90 | 91 | - Chroot validation does not distinguish between chroots and sessions. 92 | Also, `schroot::session` uses `find_alias` to find chroots, but it 93 | should specifically look for either chroots or sessions (and 94 | potentially also source chroots). Teach `schroot::chroot::config` 95 | to treat all these separately. Aliases are only useful for 96 | `SESSION_AUTOMATIC` and `BEGIN`. 97 | 98 | -------------------------------------------------------------------------------- /bin/schroot/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(schroot_sources 20 | main.h 21 | main.cc 22 | schroot.cc 23 | options.h 24 | options.cc) 25 | 26 | include_directories(${PROJECT_BINARY_DIR}/bin ${PROJECT_SOURCE_DIR}/bin) 27 | add_executable(schroot ${schroot_sources}) 28 | target_link_libraries(schroot 29 | libschroot 30 | bin-common 31 | ${Intl_LIBRARIES}) 32 | 33 | install(TARGETS schroot RUNTIME 34 | DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} 35 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE 36 | GROUP_READ GROUP_EXECUTE 37 | WORLD_READ WORLD_EXECUTE 38 | SETUID) 39 | 40 | set(installdirs 41 | ${SCHROOT_CONF_CHROOT_D} 42 | ${SCHROOT_MOUNT_DIR} 43 | ${SCHROOT_SESSION_DIR} 44 | ${SCHROOT_FILE_UNPACK_DIR} 45 | ${SCHROOT_OVERLAY_DIR} 46 | ${SCHROOT_UNDERLAY_DIR}) 47 | 48 | foreach(dir ${installdirs}) 49 | install(CODE " 50 | message(STATUS \"Installing: \$ENV{DESTDIR}${dir}\") 51 | make_directory(\"\$ENV{DESTDIR}${dir}\") 52 | ") 53 | endforeach(dir ${installdirs}) 54 | -------------------------------------------------------------------------------- /bin/schroot/schroot.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | using std::endl; 29 | using boost::format; 30 | 31 | /** 32 | * Main routine. 33 | * 34 | * @param argc the number of arguments 35 | * @param argv argument vector 36 | * 37 | * @returns 0 on success, 1 on failure or the exit status of the 38 | * chroot command. 39 | */ 40 | int 41 | main (int argc, 42 | char *argv[]) 43 | { 44 | return bin::common::run(argc, argv); 45 | } 46 | -------------------------------------------------------------------------------- /cmake/CompilerChecks.cmake: -------------------------------------------------------------------------------- 1 | set(test_flags 2 | -pedantic -Wall -Wcast-align -Wwrite-strings -Wswitch-default 3 | -Wcast-qual -Wunused-variable -Wredundant-decls 4 | -Wctor-dtor-privacy -Wnon-virtual-dtor -Wreorder -Wold-style-cast 5 | -Woverloaded-virtual -fstrict-aliasing) 6 | 7 | foreach(flag ${test_flags}) 8 | set(test_cxx_flag "CXX_FLAG${flag}") 9 | CHECK_CXX_COMPILER_FLAG(${flag} "${test_cxx_flag}") 10 | if (${test_cxx_flag}) 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") 12 | endif (${test_cxx_flag}) 13 | endforeach(flag ${test_flags}) 14 | -------------------------------------------------------------------------------- /cmake/GitReleasePolicy.cmake: -------------------------------------------------------------------------------- 1 | set(GIT_DIST_BRANCH "distribution-${GIT_RELEASE_VERSION_MAJOR}.${GIT_RELEASE_VERSION_MINOR}" 2 | CACHE STRING "Distribution branch name" FORCE) 3 | set(GIT_ARCHIVE_FORMATS tar.xz CACHE STRING "Archive formats to create" FORCE) 4 | -------------------------------------------------------------------------------- /cmake/RegexChecks.cmake: -------------------------------------------------------------------------------- 1 | include(CheckCXXSourceRuns) 2 | 3 | function(regex_test namespace header library outvar outlib) 4 | set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) 5 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${library}) 6 | check_cxx_source_runs( 7 | "#include <${header}> 8 | #include 9 | 10 | int main() { 11 | ${namespace} foo(\"^foo[bar]\$\"); 12 | ${namespace} bar(\"^foo[bar]\$\", ${namespace}::extended); 13 | ${namespace} chk(\"^[^:/,.][^:/,]*\$\", ${namespace}::extended); 14 | std::string test(\"foob\"); 15 | std::string fail(\"fail:\"); 16 | 17 | ${namespace} description_keys(\"^description\\\\\\\\[.*]$\", ${namespace}::extended); 18 | 19 | if (!${namespace}_search(test, foo)) return 1; 20 | if (!${namespace}_search(test, bar)) return 2; 21 | if (!${namespace}_search(test, chk)) return 3; 22 | if (${namespace}_search(fail, foo)) return 4; 23 | if (${namespace}_search(fail, bar)) return 5; 24 | if (${namespace}_search(fail, chk)) return 6; 25 | 26 | if (!${namespace}_match(test, foo)) return 7; 27 | if (!${namespace}_match(test, bar)) return 8; 28 | if (!${namespace}_match(test, chk)) return 9; 29 | if (${namespace}_match(fail, foo)) return 10; 30 | if (${namespace}_match(fail, bar)) return 11; 31 | if (${namespace}_match(fail, chk)) return 12; 32 | 33 | // Checks for broken support in GCC 4.9 and 5.1 34 | ${namespace} range1(\"^[a-z0-9][a-z0-9-]*\$\", ${namespace}::extended); 35 | ${namespace} range2(\"^[a-z0-9][-a-z0-9]*\$\", ${namespace}::extended); 36 | if (!${namespace}_match(test, range1)) return 13; 37 | if (!${namespace}_match(test, range2)) return 14; 38 | if (!${namespace}_match(\"a-\", range1)) return 15; 39 | if (!${namespace}_match(\"a-\", range2)) return 16; 40 | if (${namespace}_match(\"-a\", range1)) return 17; 41 | if (${namespace}_match(\"-a\", range2)) return 18; 42 | 43 | return 0; 44 | }" 45 | ${outvar}) 46 | 47 | set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) 48 | 49 | set(${outvar} ${${outvar}} PARENT_SCOPE) 50 | if (${outvar}) 51 | set(${outlib} ${library} PARENT_SCOPE) 52 | endif(${outvar}) 53 | endfunction(regex_test) 54 | 55 | regex_test(std::regex regex "" HAVE_REGEX_REGEX REGEX_LIBRARY) 56 | if(NOT HAVE_REGEX_REGEX) 57 | regex_test(std::tr1::regex tr1/regex "" HAVE_TR1_REGEX REGEX_LIBRARY) 58 | if(NOT HAVE_TR1_REGEX) 59 | regex_test(boost::regex boost/regex.hpp "${Boost_REGEX_LIBRARY_RELEASE}" HAVE_BOOST_REGEX REGEX_LIBRARY) 60 | if(NOT HAVE_BOOST_REGEX) 61 | message(FATAL_ERROR "No working regular expression implementation found") 62 | endif(NOT HAVE_BOOST_REGEX) 63 | endif(NOT HAVE_TR1_REGEX) 64 | endif(NOT HAVE_REGEX_REGEX) 65 | -------------------------------------------------------------------------------- /contrib/setup.d/05customdir: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | # This script is an example of how to use the "custom" chroot type. 21 | # This simple example replicates some of the functionality of the 22 | # "directory" chroot type, using the "custom.dir" setting in place 23 | # of the "directory" setting, which sets CUSTOM_DIR in the script 24 | # environment. Here, we bind mount it as would normally happen for 25 | # the directory type. 26 | # 27 | # Note that this replicates some of the 10mount logic, and does not 28 | # handle recovery, so is not completely robust. This will require 29 | # reworking or splitting of 10mount into separate pieces in order 30 | # to handle custom types without working the logic for the custom 31 | # types into 10mount directly (currently the recommended course of 32 | # action). 33 | 34 | set -e 35 | 36 | . "$SETUP_DATA_DIR/common-data" 37 | . "$SETUP_DATA_DIR/common-functions" 38 | . "$SETUP_DATA_DIR/common-config" 39 | 40 | # Mount a filesystem 41 | # $1: mount options 42 | # $2: mount device 43 | # $3: mount location 44 | do_mount() 45 | { 46 | info "Mounting $2 on $3" 47 | 48 | if [ ! -d "$3" ]; then 49 | mkdir -p "$3" 50 | fi 51 | if [ ! -d "$3" ]; then 52 | fatal "$3 does not exist, and could not be created" 53 | fi 54 | 55 | info "$MOUNT_VERBOSE $1 $2 $3" 56 | mount $MOUNT_VERBOSE $1 "$2" "$3" 57 | } 58 | 59 | if [ "$CHROOT_TYPE" = "custom" ] && [ -n "$CUSTOM_DIR" ]; then 60 | 61 | if [ $STAGE = "setup-start" ]; then 62 | 63 | info "CUSTOM SETUP using $CUSTOM_DIR" 64 | 65 | case "$(uname -s)" in 66 | *FreeBSD) : 67 | BINDOPT="-t nullfs" 68 | ;; 69 | *): 70 | BINDOPT="--bind" 71 | ;; 72 | esac 73 | 74 | CHROOT_MOUNT_OPTIONS="$BINDOPT $CHROOT_MOUNT_OPTIONS" 75 | CHROOT_MOUNT_DEVICE="$CUSTOM_DIR" 76 | 77 | if [ ! -d "$CUSTOM_DIR" ]; then 78 | fatal "Directory '$CUSTOM_DIR' does not exist" 79 | fi 80 | 81 | if [ ! -d "$CHROOT_MOUNT_LOCATION" ]; then 82 | mkdir -p "$CHROOT_MOUNT_LOCATION" 83 | fi 84 | if [ ! -d "$CHROOT_MOUNT_LOCATION" ]; then 85 | fatal "$CHROOT_MOUNT_LOCATION does not exist, and could not be created" 86 | fi 87 | 88 | do_mount "$CHROOT_MOUNT_OPTIONS" "$CHROOT_MOUNT_DEVICE" "$CHROOT_MOUNT_LOCATION" 89 | 90 | fi 91 | 92 | fi 93 | 94 | -------------------------------------------------------------------------------- /contrib/setup.d/09fsck: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2007 Roger Leigh 3 | # Copyright © 2008-2009 Martin F. Krafft 4 | # 5 | # schroot is free software: you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # schroot is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see 17 | # . 18 | # 19 | ##################################################################### 20 | 21 | set -e 22 | 23 | if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then 24 | . "$CHROOT_SCRIPT_CONFIG" 25 | fi 26 | 27 | if [ "$VERBOSE" = "verbose" ]; then 28 | FSCK_VERBOSE="-V" 29 | fi 30 | 31 | if [ "$CHROOT_TYPE" = "block-device" ]; then 32 | 33 | if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then 34 | ret=0 35 | /sbin/fsck $FSCK_VERBOSE -Ta "$CHROOT_MOUNT_DEVICE" || ret=$? 36 | 37 | case "$ret" in 38 | 0|1) :;; 39 | *) 40 | echo "fsck failed with return code $ret (see fsck(8))." >&2 41 | exit 1 42 | ;; 43 | esac 44 | fi 45 | fi 46 | -------------------------------------------------------------------------------- /contrib/setup.d/10mount-ssh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright © 2010 Sascha Silbe 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License version 3 6 | # as published by the Free Software Foundation. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | # 10mount-ssh: "Forward" ssh-agent to chroot. 19 | # Performs a bind-mount of the ssh-agent socket directory. Clean-up 20 | # happens at session end in setup.d/10mount. 21 | ##################################################################### 22 | 23 | set -e 24 | 25 | ACTION="$1" 26 | STATUS="$2" 27 | 28 | if [ "$STATUS" != ok ] ; then 29 | exit 0 30 | fi 31 | 32 | # Extract SSH_AUTH_SOCK from environment of schroot process ($PID) 33 | SSH_AUTH_SOCK="$(tr '\0' '\n' < /proc/"$PID"/environ | grep ^SSH_AUTH_SOCK | head -n 1 |sed -e 's/^SSH_AUTH_SOCK=//')" 34 | if [ -z "${SSH_AUTH_SOCK:-}" ] ; then 35 | exit 0 36 | fi 37 | 38 | SOCK_DIR="$(dirname "${SSH_AUTH_SOCK}")" 39 | 40 | if [ "$ACTION" = "setup-start" ] ; then 41 | if [ -e "${CHROOT_PATH}/${SSH_AUTH_SOCK}" ] ; then 42 | exit 0 43 | fi 44 | mkdir -p "${CHROOT_PATH}/${SOCK_DIR}" 45 | mount -o bind "${SOCK_DIR}" "${CHROOT_PATH}/${SOCK_DIR}" 46 | fi 47 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | if(BUILD_DOXYGEN) 20 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/schroot.dox.cmake 21 | ${CMAKE_CURRENT_BINARY_DIR}/schroot.dox @ONLY) 22 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/schroot-bin.dox.cmake 23 | ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.dox @ONLY) 24 | 25 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/schroot.log 26 | COMMAND ${CMAKE_COMMAND} -E remove_directory schroot 27 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/schroot.dox 28 | COMMAND ${CMAKE_COMMAND} -E echo "══════════ UNDOCUMENTED CODE ══════════" 29 | COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/schroot.log 30 | COMMAND ${CMAKE_COMMAND} -E echo "═════════ END UNDOCUMENTED CODE ═══════" 31 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/schroot.dox) 32 | 33 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.log 34 | COMMAND ${CMAKE_COMMAND} -E remove_directory schroot-bin 35 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.dox 36 | COMMAND ${CMAKE_COMMAND} -E echo "══════════ UNDOCUMENTED CODE ══════════" 37 | COMMAND cat ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.log 38 | COMMAND ${CMAKE_COMMAND} -E echo "═════════ END UNDOCUMENTED CODE ═══════" 39 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.dox) 40 | 41 | add_custom_target(doc DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/schroot.log ${CMAKE_CURRENT_BINARY_DIR}/schroot-bin.log) 42 | endif(BUILD_DOXYGEN) 43 | -------------------------------------------------------------------------------- /doc/REQUIREMENTS: -------------------------------------------------------------------------------- 1 | Requirements -*- outline -*- 2 | ------------ 3 | 4 | * Allow a user to chroot() into a location specified in a configuration file. 5 | 6 | This will require the program to be setuid-root. 7 | 8 | * Allow the user to run a command or a login shell. 9 | 10 | * Allow the user to preserve their environment inside the chroot. 11 | 12 | This should not be the default. 13 | 14 | * Restrict access to the chroot to certain users or groups. 15 | 16 | Group restrictions are easiest to administer, and the default is to 17 | create users with their own group anyway. 18 | 19 | * Allow root access to non-root users. 20 | 21 | root access is required in order to install and remove packages in 22 | the root (i.e. general apt/dpkg stuff). 23 | 24 | In order for tools like sbuild to run non-interactively, this should 25 | be password-less if the user is authorised to have root access in 26 | the chroot. 27 | 28 | * Allow changing to other users, in addition to root, in the same manner as su(1). 29 | 30 | This will require authentication. 31 | 32 | * Allow querying of the available chroots. 33 | 34 | Tools need to know the available chroots, and should not be required 35 | to parse the configuration file by hand. 36 | -------------------------------------------------------------------------------- /etc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(schroot_sysconf_data 20 | schroot.conf) 21 | 22 | install(FILES ${schroot_sysconf_data} 23 | DESTINATION ${SCHROOT_SYSCONF_DIR}) 24 | 25 | set(files 26 | copyfiles 27 | fstab 28 | nssdatabases) 29 | 30 | set(profiles 31 | buildd 32 | default 33 | desktop 34 | minimal 35 | sbuild) 36 | 37 | set(arches 38 | ${SBUILD_PLATFORM}) 39 | 40 | foreach(profile ${profiles}) 41 | foreach(file ${files}) 42 | file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/profiles/${profile}") 43 | set(output_file "${CMAKE_CURRENT_BINARY_DIR}/profiles/${profile}/${file}") 44 | foreach(arch ${arches}) 45 | if(EXISTS ${output_file}) 46 | file(REMOVE ${output_file}) 47 | endif(EXISTS ${output_file}) 48 | foreach(source_file 49 | ${CMAKE_CURRENT_SOURCE_DIR}/profile-templates/all/all/${file} 50 | ${CMAKE_CURRENT_SOURCE_DIR}/profile-templates/all/${arch}/${file} 51 | ${CMAKE_CURRENT_SOURCE_DIR}/profile-templates/${profile}/all/${file} 52 | ${CMAKE_CURRENT_SOURCE_DIR}/profile-templates/${profile}/${arch}/${file}) 53 | if(EXISTS ${source_file}) 54 | file(READ ${source_file} content) 55 | if(EXISTS ${source_file}) 56 | file(APPEND ${output_file} ${content}) 57 | else(EXISTS ${source_file}) 58 | file(WRITE ${output_file} ${content}) 59 | endif(EXISTS ${source_file}) 60 | endif(EXISTS ${source_file}) 61 | endforeach(source_file) 62 | if(EXISTS ${output_file}) 63 | message(STATUS "Generated schroot profile ${profile}/${file}") 64 | install(FILES ${output_file} 65 | DESTINATION ${SCHROOT_SYSCONF_DIR}/${profile}) 66 | endif(EXISTS ${output_file}) 67 | endforeach(arch) 68 | endforeach(file) 69 | endforeach(profile) 70 | 71 | add_subdirectory(pam) 72 | add_subdirectory(bash_completion) 73 | add_subdirectory(setup.d) 74 | -------------------------------------------------------------------------------- /etc/bash_completion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(bash_completion_data schroot) 20 | 21 | install(FILES ${bash_completion_data} 22 | DESTINATION ${bash_completion_dir}) 23 | -------------------------------------------------------------------------------- /etc/bash_completion/schroot: -------------------------------------------------------------------------------- 1 | # Debian GNU/Linux schroot(1) completion. 2 | # Copyright © 2009 Tim Abbott 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | 18 | have schroot && 19 | _schroot() 20 | { 21 | local cur prev options 22 | 23 | COMPREPLY=() 24 | cur=${COMP_WORDS[COMP_CWORD]} 25 | prev=${COMP_WORDS[COMP_CWORD-1]} 26 | 27 | # Select precisely the tokens from schroot --help that begin with a dash 28 | options=$(schroot --help | sed 's/\(^\|[[:space:]]\)[^[:space:]-][^[:space:]]*//g') 29 | 30 | if [ "$prev" = "-c" ] || [ "$prev" = "--chroot" ]; then 31 | COMPREPLY=( $(compgen -W "$(schroot -a -l)" -- $cur) ) 32 | else 33 | COMPREPLY=( $(compgen -W "$options" -- $cur) ) 34 | fi 35 | return 0 36 | } 37 | complete -F _schroot schroot 38 | -------------------------------------------------------------------------------- /etc/pam/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(pam_data schroot) 20 | set(pam_dir "/etc/pam.d") 21 | 22 | install(FILES ${pam_data} 23 | DESTINATION ${pam_dir}) 24 | -------------------------------------------------------------------------------- /etc/pam/schroot: -------------------------------------------------------------------------------- 1 | # 2 | # The PAM configuration file for the schroot service 3 | # 4 | 5 | # Uncomment this to force users to be a member of group root 6 | # before they can use `schroot'. You can also add "group=foo" 7 | # to the end of this line if you want to use a group other 8 | # than the default "root". 9 | # auth required pam_wheel.so 10 | 11 | # Uncomment this if you want wheel members to be able to use 12 | # chroot without a password. 13 | # auth sufficient pam_wheel.so trust 14 | 15 | # Uncomment this if you want members of a specific group to not 16 | # be allowed to use schroot at all. 17 | # auth required pam_wheel.so deny group=noschroot 18 | 19 | # This allows root to use schroot without passwords (normal operation) 20 | auth sufficient pam_rootok.so 21 | 22 | # Uncomment and edit /etc/security/time.conf if you need to set 23 | # time restrainst on schroot usage. 24 | # account requisite pam_time.so 25 | 26 | # The standard Unix authentication modules, used with 27 | # NIS (man nsswitch) as well as normal /etc/passwd and 28 | # /etc/shadow entries. 29 | @include common-auth 30 | @include common-account 31 | @include common-session 32 | 33 | # Sets up user limits, please uncomment and read /etc/security/limits.conf 34 | # to enable this functionality. 35 | # session required pam_limits.so 36 | -------------------------------------------------------------------------------- /etc/profile-templates/all/all/copyfiles: -------------------------------------------------------------------------------- 1 | # Files to copy into the chroot from the host system. 2 | # 3 | # 4 | /etc/resolv.conf 5 | -------------------------------------------------------------------------------- /etc/profile-templates/all/all/fstab: -------------------------------------------------------------------------------- 1 | # fstab: static file system information for chroots. 2 | # Note that the mount point will be prefixed by the chroot path 3 | # (CHROOT_PATH) 4 | # 5 | # 6 | -------------------------------------------------------------------------------- /etc/profile-templates/all/all/nssdatabases: -------------------------------------------------------------------------------- 1 | # System databases to copy into the chroot from the host system. 2 | # 3 | # 4 | passwd 5 | shadow 6 | group 7 | gshadow 8 | -------------------------------------------------------------------------------- /etc/profile-templates/all/freebsd/fstab: -------------------------------------------------------------------------------- 1 | proc /proc linprocfs defaults 0 0 2 | -------------------------------------------------------------------------------- /etc/profile-templates/all/gnu/fstab: -------------------------------------------------------------------------------- 1 | /proc /proc none bind 0 0 2 | /dev /dev none bind 0 0 3 | /servers /servers none bind 0 0 4 | -------------------------------------------------------------------------------- /etc/profile-templates/all/linux/fstab: -------------------------------------------------------------------------------- 1 | /proc /proc none rw,bind 0 0 2 | /sys /sys none rw,bind 0 0 3 | -------------------------------------------------------------------------------- /etc/profile-templates/buildd/all/copyfiles: -------------------------------------------------------------------------------- 1 | # Files to copy into the chroot from the host system. 2 | # 3 | # 4 | /etc/hosts 5 | /etc/resolv.conf 6 | /etc/networks 7 | -------------------------------------------------------------------------------- /etc/profile-templates/buildd/all/nssdatabases: -------------------------------------------------------------------------------- 1 | # System databases to copy into the chroot from the host system. 2 | # 3 | # 4 | passwd 5 | shadow 6 | group 7 | gshadow 8 | -------------------------------------------------------------------------------- /etc/profile-templates/buildd/freebsd/fstab: -------------------------------------------------------------------------------- 1 | dev /dev devfs rw,bind 0 0 2 | dev /dev/fd fdescfs rw,bind 0 0 3 | /home/buildd/build-trees /build nullfs rw 0 0 4 | -------------------------------------------------------------------------------- /etc/profile-templates/buildd/linux/fstab: -------------------------------------------------------------------------------- 1 | /dev/pts /dev/pts none rw,bind 0 0 2 | tmpfs /dev/shm tmpfs defaults 0 0 3 | # Mount a large scratch space for the build, so we don't use up 4 | # space on an LVM snapshot of the chroot itself. 5 | /var/lib/sbuild/build /build none rw,bind 0 0 6 | -------------------------------------------------------------------------------- /etc/profile-templates/default/all/nssdatabases: -------------------------------------------------------------------------------- 1 | services 2 | protocols 3 | networks 4 | hosts 5 | -------------------------------------------------------------------------------- /etc/profile-templates/default/freebsd/fstab: -------------------------------------------------------------------------------- 1 | dev /dev devfs rw,bind 0 0 2 | dev /dev/fd fdescfs rw,bind 0 0 3 | /home /home nullfs rw 0 0 4 | /tmp /tmp nullfs rw 0 0 5 | 6 | # It may be desirable to have access to /run, especially if you wish 7 | # to run additional services in the chroot. However, note that this 8 | # may potentially cause undesirable behaviour on upgrades, such as 9 | # killing services on the host. 10 | #/run /run nullfs rw 0 0 11 | #/run/lock /run/lock nullfs rw 0 0 12 | -------------------------------------------------------------------------------- /etc/profile-templates/default/gnu/fstab: -------------------------------------------------------------------------------- 1 | /home /home none bind 0 0 2 | /tmp /tmp none bind 0 0 3 | 4 | # It may be desirable to have access to /run, especially if you wish 5 | # to run additional services in the chroot. However, note that this 6 | # may potentially cause undesirable behaviour on upgrades, such as 7 | # killing services on the host. 8 | #/run /run none bind 0 0 9 | #/run/lock /run/lock none bind 0 0 10 | #/dev/shm /dev/shm none bind 0 0 11 | #/run/shm /run/shm none bind 0 0 12 | -------------------------------------------------------------------------------- /etc/profile-templates/default/linux/fstab: -------------------------------------------------------------------------------- 1 | /dev /dev none rw,bind 0 0 2 | /dev/pts /dev/pts none rw,bind 0 0 3 | /home /home none rw,bind 0 0 4 | /tmp /tmp none rw,bind 0 0 5 | 6 | # It may be desirable to have access to /run, especially if you wish 7 | # to run additional services in the chroot. However, note that this 8 | # may potentially cause undesirable behaviour on upgrades, such as 9 | # killing services on the host. 10 | #/run /run none rw,bind 0 0 11 | #/run/lock /run/lock none rw,bind 0 0 12 | #/dev/shm /dev/shm none rw,bind 0 0 13 | #/run/shm /run/shm none rw,bind 0 0 14 | -------------------------------------------------------------------------------- /etc/profile-templates/desktop/all/nssdatabases: -------------------------------------------------------------------------------- 1 | services 2 | protocols 3 | networks 4 | hosts 5 | -------------------------------------------------------------------------------- /etc/profile-templates/desktop/freebsd/fstab: -------------------------------------------------------------------------------- 1 | dev /dev devfs rw,bind 0 0 2 | dev /dev/fd fdescfs rw,bind 0 0 3 | /home /home nullfs rw 0 0 4 | /tmp /tmp nullfs rw 0 0 5 | 6 | # For PulseAudio and other desktop-related things 7 | /var/lib/dbus /var/lib/dbus none rw,bind 0 0 8 | 9 | # It may be desirable to have access to /run, especially if you wish 10 | # to run additional services in the chroot. However, note that this 11 | # may potentially cause undesirable behaviour on upgrades, such as 12 | # killing services on the host. 13 | #/run /run nullfs rw 0 0 14 | #/run/lock /run/lock nullfs rw 0 0 15 | -------------------------------------------------------------------------------- /etc/profile-templates/desktop/gnu/fstab: -------------------------------------------------------------------------------- 1 | /home /home none bind 0 0 2 | /tmp /tmp none bind 0 0 3 | 4 | # If you use gdm3, uncomment this line to allow Xauth to work 5 | #/var/run/gdm3 /var/run/gdm3 none bind 0 0 6 | # For PulseAudio and other desktop-related things 7 | /var/lib/dbus /var/lib/dbus none bind 0 0 8 | 9 | # It may be desirable to have access to /run, especially if you wish 10 | # to run additional services in the chroot. However, note that this 11 | # may potentially cause undesirable behaviour on upgrades, such as 12 | # killing services on the host. 13 | #/run /run none bind 0 0 14 | #/run/lock /run/lock none bind 0 0 15 | #/dev/shm /dev/shm none bind 0 0 16 | #/run/shm /run/shm none bind 0 0 17 | -------------------------------------------------------------------------------- /etc/profile-templates/desktop/linux/fstab: -------------------------------------------------------------------------------- 1 | /dev /dev none rw,bind 0 0 2 | /dev/pts /dev/pts none rw,bind 0 0 3 | /home /home none rw,bind 0 0 4 | /tmp /tmp none rw,bind 0 0 5 | 6 | # If you use gdm3, uncomment this line to allow Xauth to work 7 | #/var/run/gdm3 /var/run/gdm3 none rw,bind 0 0 8 | # For PulseAudio and other desktop-related things 9 | /var/lib/dbus /var/lib/dbus none rw,bind 0 0 10 | 11 | # It may be desirable to have access to /run, especially if you wish 12 | # to run additional services in the chroot. However, note that this 13 | # may potentially cause undesirable behaviour on upgrades, such as 14 | # killing services on the host. 15 | #/run /run none rw,bind 0 0 16 | #/run/lock /run/lock none rw,bind 0 0 17 | #/dev/shm /dev/shm none rw,bind 0 0 18 | #/run/shm /run/shm none rw,bind 0 0 19 | -------------------------------------------------------------------------------- /etc/profile-templates/sbuild/freebsd/fstab: -------------------------------------------------------------------------------- 1 | dev /dev devfs rw,bind 0 0 2 | dev /dev/fd fdescfs rw,bind 0 0 3 | # Mount a large scratch space for the build, so we don't use up 4 | # space on an LVM snapshot of the chroot itself. 5 | /var/lib/sbuild/build /build nullfs rw 0 0 6 | -------------------------------------------------------------------------------- /etc/profile-templates/sbuild/linux/fstab: -------------------------------------------------------------------------------- 1 | /dev/pts /dev/pts none rw,bind 0 0 2 | tmpfs /dev/shm tmpfs defaults 0 0 3 | # Mount a large scratch space for the build, so we don't use up 4 | # space on an LVM snapshot of the chroot itself. 5 | /var/lib/sbuild/build /build none rw,bind 0 0 6 | -------------------------------------------------------------------------------- /etc/schroot.conf: -------------------------------------------------------------------------------- 1 | # schroot chroot definitions. 2 | # See schroot.conf(5) for complete documentation of the file format. 3 | # 4 | # Please take note that you should not add untrusted users to 5 | # root-groups, because they will essentially have full root access 6 | # to your system. They will only have root access inside the chroot, 7 | # but that's enough to cause malicious damage. 8 | # 9 | # The following lines are examples only. Uncomment and alter them to 10 | # customise schroot for your needs, or create a new entry from scratch. 11 | # 12 | # 13 | #[sid] 14 | #description=Debian sid (unstable) 15 | #directory=/srv/chroot/sid 16 | #users=rleigh 17 | #groups=sbuild 18 | #root-groups=root 19 | #aliases=unstable,default 20 | # 21 | #[sid-snap] 22 | #type=btrfs-snapshot 23 | #description=Debian sid btrfs snapshot 24 | #btrfs-source-subvolume=/srv/chroot/sid-snap 25 | #btrfs-snapshot-directory=/srv/chroot/snapshots 26 | #groups=root,sbuild 27 | #root-groups=root,sbuild 28 | # 29 | #[squeeze] 30 | #description=Debian squeeze (stable) 32-bit 31 | #directory=/srv/chroot/squeeze 32 | #groups=sbuild-security 33 | #aliases=stable 34 | #personality=linux32 35 | # 36 | #[lenny] 37 | #description=Debian lenny (oldstable) 38 | #directory=/srv/chroot/lenny 39 | #groups=sbuild 40 | #aliases=oldstable 41 | # 42 | #[lenny-file] 43 | #description=Debian lenny (oldstable) 44 | #file=/srv/chroot/lenny.tar.gz 45 | #location=/lenny 46 | #groups=sbuild 47 | # 48 | #[lenny-secure] 49 | #description=Debian lenny (oldstable) 50 | #directory=/srv/chroot/lenny 51 | #groups=sbuild-security 52 | #aliases=stable-security 53 | # 54 | #[experimental] 55 | #type=block-device 56 | #description=Debian experimental 57 | #groups=sbuild,root 58 | #root-groups=root,sbuild 59 | #device=/dev/hda_vg/experimental_chroot 60 | #mount-options=-o atime,sync,user_xattr 61 | #location=/experimental 62 | -------------------------------------------------------------------------------- /etc/setup.d/00check: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | # Plain chroots should not be able to use scripts, but check anyway to 27 | # be safe. 28 | if [ $CHROOT_TYPE = "plain" ]; then 29 | fatal "plain chroots may not run setup scripts; use directory instead" 30 | fi 31 | 32 | # Skip if run at inappropriate point. 33 | if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ] && [ "$(basename "$0")" = "99check" ]; then 34 | exit 0; 35 | elif [ $STAGE = "setup-stop" ] && [ "$(basename "$0")" = "00check" ]; then 36 | exit 0; 37 | fi 38 | 39 | info "STAGE=$STAGE" 40 | info "STATUS=$STATUS" 41 | if [ "$VERBOSE" = "verbose" ]; then 42 | env | sort 43 | fi 44 | 45 | # A basic safety check, so that the root filesystem doesn't get 46 | # toasted by accident. 47 | if [ -z "$CHROOT_PATH" ] \ 48 | || [ "$CHROOT_PATH" = "/" ] \ 49 | || ( [ -z "$CHROOT_UNION_TYPE" ] \ 50 | && [ "$CHROOT_DIRECTORY" = "/" ] ) \ 51 | || [ "$CHROOT_UNION_OVERLAY_DIRECTORY" = "/" ] 52 | then 53 | fatal "Invalid chroot mount path or directory" 54 | fi 55 | -------------------------------------------------------------------------------- /etc/setup.d/05btrfs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | if [ "$CHROOT_TYPE" = "btrfs-snapshot" ]; then 27 | 28 | if [ $STAGE = "setup-start" ]; then 29 | 30 | if [ ! -d "$CHROOT_BTRFS_SOURCE_SUBVOLUME" ]; then 31 | fatal "Btrfs source subvolume directory '$CHROOT_BTRFS_SOURCE_SUBVOLUME' does not exist" 32 | fi 33 | if [ ! -d "$CHROOT_BTRFS_SNAPSHOT_DIRECTORY" ]; then 34 | fatal "Btrfs snapshot directory '$CHROOT_BTRFS_SNAPSHOT_DIRECTORY' does not exist" 35 | fi 36 | 37 | info "Creating snapshot $CHROOT_BTRFS_SNAPSHOT_NAME from subvolume $CHROOT_BTRFS_SOURCE_SUBVOLUME" 38 | 39 | if [ "$VERBOSE" = "verbose" ]; then 40 | btrfs subvolume snapshot "$CHROOT_BTRFS_SOURCE_SUBVOLUME" \ 41 | "$CHROOT_BTRFS_SNAPSHOT_NAME" 42 | else 43 | btrfs subvolume snapshot "$CHROOT_BTRFS_SOURCE_SUBVOLUME" \ 44 | "$CHROOT_BTRFS_SNAPSHOT_NAME" > /dev/null 45 | fi 46 | 47 | elif [ $STAGE = "setup-stop" ]; then 48 | 49 | if [ -d "$CHROOT_BTRFS_SNAPSHOT_NAME" ]; then 50 | 51 | info "Deleting snapshot $CHROOT_BTRFS_SNAPSHOT_NAME" 52 | 53 | if [ "$VERBOSE" = "verbose" ]; then 54 | btrfs subvolume delete "$CHROOT_BTRFS_SNAPSHOT_NAME" || true 55 | else 56 | btrfs subvolume delete "$CHROOT_BTRFS_SNAPSHOT_NAME" > /dev/null || true 57 | fi 58 | 59 | else 60 | # The block device no longer exists, or was never created, 61 | # for example on lvcreate failure. 62 | warn "$CHROOT_BTRFS_SNAPSHOT_NAME does not exist (it may have been removed previously)" 63 | fi 64 | 65 | fi 66 | 67 | fi 68 | 69 | -------------------------------------------------------------------------------- /etc/setup.d/05union: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2008-2013 Jan-Marek Glogowski 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | if [ -n "${CHROOT_UNION_TYPE}" ] && [ "${CHROOT_UNION_TYPE}" != 'none' ]; then 27 | 28 | if [ $STAGE = "setup-start" ]; then 29 | mkdir "${CHROOT_UNION_OVERLAY_DIRECTORY}" 30 | if [ ! -d "$CHROOT_UNION_OVERLAY_DIRECTORY" ]; then 31 | fatal "$CHROOT_UNION_OVERLAY_DIRECTORY does not exist, and could not be created" 32 | fi 33 | 34 | mkdir "${CHROOT_UNION_UNDERLAY_DIRECTORY}" 35 | if [ ! -d "$CHROOT_UNION_UNDERLAY_DIRECTORY" ]; then 36 | fatal "$CHROOT_UNION_UNDERLAY_DIRECTORY does not exist, and could not be created" 37 | fi 38 | 39 | elif [ $STAGE = "setup-recover" ]; then 40 | if [ ! -d "${CHROOT_UNION_OVERLAY_DIRECTORY}" ]; then 41 | fatal "Missing overlay directory for session: can't recover" 42 | fi 43 | if [ ! -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then 44 | fatal "Missing underlay directory for session: can't recover" 45 | fi 46 | 47 | elif [ $STAGE = "setup-stop" ]; then 48 | if [ "$CHROOT_SESSION_PURGE" = "true" ]; then 49 | info "Purging $CHROOT_UNION_OVERLAY_DIRECTORY" 50 | if [ -d "${CHROOT_UNION_OVERLAY_DIRECTORY}" ]; then 51 | rm -rf "${CHROOT_UNION_OVERLAY_DIRECTORY}" 52 | fi 53 | 54 | # For safety, use rmdir rather than rm -rf in case 55 | # umount failed. 56 | info "Removing $CHROOT_UNION_UNDERLAY_DIRECTORY" 57 | if [ -d "${CHROOT_UNION_UNDERLAY_DIRECTORY}" ]; then 58 | if ! rmdir "${CHROOT_UNION_UNDERLAY_DIRECTORY}"; then 59 | warn "Please unmount any filesystems and remove any files under $CHROOT_UNION_UNDERLAY_DIRECTORY" 60 | fatal "Failed to remove $CHROOT_UNION_UNDERLAY_DIRECTORY (directory not empty)." 61 | fi 62 | fi 63 | fi 64 | fi 65 | 66 | fi 67 | 68 | -------------------------------------------------------------------------------- /etc/setup.d/15binfmt: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2011-2013 Julian Andres Klode 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | 27 | if [ "$STAGE" != "setup-start" ] && \ 28 | [ "$STAGE" != "setup-stop" ] && \ 29 | [ "$STAGE" != "setup-recover" ]; then 30 | exit 0 31 | elif ! which update-binfmts > /dev/null 2>&1; then 32 | info "Missing update-binfmts; not enabling binfmt support" 33 | exit 0 34 | fi 35 | 36 | shell="${CHROOT_PATH}/bin/sh" 37 | 38 | for emulator in $(update-binfmts --find "$shell"); do 39 | dst="${CHROOT_PATH}$emulator" 40 | if [ ! -e "$emulator" ]; then 41 | info "Missing emulator: $emulator; not enabling binfmt support" 42 | else 43 | [ -e "$dst" ] || touch "$dst" 44 | mount --bind "$emulator" "$dst" 45 | mount -o remount,ro,bind "$dst" 46 | fi 47 | done 48 | -------------------------------------------------------------------------------- /etc/setup.d/15killprocs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2007 Kees Cook 3 | # Copyright © 2007-2013 Roger Leigh 4 | # 5 | # schroot is free software: you can redistribute it and/or modify it 6 | # under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # schroot is distributed in the hope that it will be useful, but 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | # General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see 17 | # . 18 | # 19 | ##################################################################### 20 | 21 | set -e 22 | 23 | . "$SETUP_DATA_DIR/common-data" 24 | . "$SETUP_DATA_DIR/common-functions" 25 | . "$SETUP_DATA_DIR/common-config" 26 | 27 | # Wrapper around kill command. Turns errors into 28 | # warnings when running in verbose mode, otherwise 29 | # it ignores them. 30 | # args: parameters for kill 31 | kill_proc() 32 | { 33 | if ! kill "$@" 2>/dev/null; then 34 | info "kill $@ failed: process already terminated?" 35 | fi 36 | } 37 | 38 | # Kill all processes that were run from within the chroot environment 39 | # $1: mount base location 40 | do_kill_all() 41 | { 42 | if [ -z "$1" ]; then 43 | fatal "No path for finding stray processes: not reaping processes in chroot" 44 | fi 45 | 46 | info "Killing processes run inside $1" 47 | ls /proc | egrep '^[[:digit:]]+$' | 48 | while read pid; do 49 | # Check if process root are the same device/inode as chroot 50 | # root (for efficiency) 51 | if [ /proc/"$pid"/root -ef "$1" ]; then 52 | # Check if process and chroot root are the same (may be 53 | # different even if device/inode match). 54 | root=$(readlink /proc/"$pid"/root || true) 55 | if [ "$root" = "$1" ]; then 56 | exe=$(readlink /proc/"$pid"/exe || true) 57 | info "Killing left-over pid $pid (${exe##$1})" 58 | info " Sending SIGTERM to pid $pid" 59 | 60 | kill_proc -TERM "$pid" 61 | 62 | count=0 63 | max=5 64 | while [ -d /proc/"$pid" ]; do 65 | count=$(( $count + 1 )) 66 | info " Waiting for pid $pid to shut down... ($count/$max)" 67 | sleep 1 68 | # Wait for $max seconds for process to die before -9'ing it 69 | if [ "$count" -eq "$max" ]; then 70 | info " Sending SIGKILL to pid $pid" 71 | kill_proc -KILL "$pid" 72 | sleep 1 73 | break 74 | fi 75 | done 76 | fi 77 | fi 78 | done 79 | } 80 | 81 | if [ $STAGE = "setup-recover" ] || [ $STAGE = "setup-stop" ]; then 82 | do_kill_all "$CHROOT_PATH" 83 | fi 84 | -------------------------------------------------------------------------------- /etc/setup.d/20copyfiles: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | if [ "$VERBOSE" = "verbose" ]; then 27 | CP_VERBOSE="--verbose" 28 | fi 29 | 30 | # Copy a file if the source and destination differ 31 | # $1: source file 32 | # $2: destination file 33 | copy_file() 34 | { 35 | if [ -e "$1" ]; then 36 | 37 | COPY="true" 38 | 39 | if [ -e "$2" ]; then 40 | 41 | # Device and inode 42 | da=$(/usr/bin/stat --format="%d %i" "$1") 43 | # This one can fail since it might not exist yet 44 | db=$(/usr/bin/stat --format="%d %i" "$2" 2>/dev/null || :) 45 | 46 | if [ "$da" = "$db" ]; then 47 | COPY="false" 48 | elif [ -L "$2" ]; then 49 | # Copy if destination is a symlink 50 | : 51 | elif [ -f "$1" ] && [ -f "$2" ]; then 52 | # Content 53 | ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') 54 | cb=$(/usr/bin/md5sum "$2" 2>/dev/null || :) 55 | cb=$(echo "$cb" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') 56 | # Copy only if file contents differ 57 | if [ "$ca" = "$cb" ]; then 58 | COPY="false" 59 | fi 60 | fi 61 | fi 62 | 63 | # Copy only if files are different 64 | if [ "$COPY" = "true" ]; then 65 | if [ -f "$1" ]; then 66 | cp --preserve=all $CP_VERBOSE "$1" "$2" 67 | else 68 | # Copy non-regular file directly 69 | cp -a $CP_VERBOSE "$1" "$2" 70 | fi 71 | fi 72 | 73 | else 74 | fatal "Not copying nonexistent file: $file" 75 | fi 76 | } 77 | 78 | if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then 79 | 80 | if [ -n "$SETUP_COPYFILES" ]; then 81 | if [ -f "$SETUP_COPYFILES" ]; then 82 | while read file; do 83 | if echo "$file" | egrep -q '^(#|$)' ; then 84 | continue 85 | fi 86 | if echo "$file" | grep -q '^/'; then 87 | copy_file "$file" "${CHROOT_PATH}$file" 88 | else 89 | warn "Not copying file with relative path: $file" 90 | fi 91 | done < "$SETUP_COPYFILES" 92 | else 93 | fatal "copyfiles file '$SETUP_COPYFILES' does not exist" 94 | fi 95 | fi 96 | 97 | fi 98 | 99 | -------------------------------------------------------------------------------- /etc/setup.d/20nssdatabases: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | # Copy NSS database from host to chroot 27 | # $1: database name 28 | # $2: destination file name 29 | dup_nss() 30 | { 31 | info "Copying $1 database to $2" 32 | getent "$1" > "$2" 33 | } 34 | 35 | if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then 36 | 37 | if [ -n "$SETUP_NSSDATABASES" ]; then 38 | if [ -f "$SETUP_NSSDATABASES" ]; then 39 | while read db; do 40 | if echo "$db" | egrep -q '^(#|$)' ; then 41 | continue 42 | fi 43 | 44 | # Device and inode 45 | dr=$(/usr/bin/stat --format="%d %i" "/etc/$db") 46 | # This one can fail since it might not exist yet 47 | dc=$(/usr/bin/stat --format="%d %i" "${CHROOT_PATH}/etc/$db" 2>/dev/null || :) 48 | 49 | # If the database inside and outside the chroot is the 50 | # same, it's very likely that dup_nss would blank the 51 | # database, so skip it. 52 | if [ "$dr" = "$dc" ]; then 53 | warn "$db files '/etc/$db' and '${CHROOT_PATH}/etc/$db' are the same file; skipping" 54 | continue; 55 | fi 56 | 57 | dup_nss "$db" "${CHROOT_PATH}/etc/$db" 58 | done < "$SETUP_NSSDATABASES" 59 | else 60 | fatal "nssdatabases file '$SETUP_NSSDATABASES' does not exist" 61 | fi 62 | fi 63 | 64 | fi 65 | 66 | -------------------------------------------------------------------------------- /etc/setup.d/50chrootname: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2005-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | set -e 21 | 22 | . "$SETUP_DATA_DIR/common-data" 23 | . "$SETUP_DATA_DIR/common-functions" 24 | . "$SETUP_DATA_DIR/common-config" 25 | 26 | if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then 27 | 28 | info "Setting chroot name to ${CHROOT_NAME}" 29 | 30 | echo "${CHROOT_NAME}" > "${CHROOT_PATH}/etc/debian_chroot" 31 | 32 | fi 33 | 34 | -------------------------------------------------------------------------------- /etc/setup.d/60unshare: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2012-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | # Disassociates process execution context inside the chroot. 21 | # If unsharing network CLONE_NEWNET, this has stopped all networking. 22 | # We therefore need to bring up the lo interface to have working 23 | # loopback. 24 | 25 | set -e 26 | 27 | . "$SETUP_DATA_DIR/common-data" 28 | . "$SETUP_DATA_DIR/common-functions" 29 | . "$SETUP_DATA_DIR/common-config" 30 | 31 | if [ $STAGE = "exec-start" ]; then 32 | 33 | if [ "$UNSHARE_NEWNET" = "true" ]; then 34 | info "Bringing up netdev lo" 35 | ip link set dev lo up 36 | fi 37 | 38 | fi 39 | 40 | -------------------------------------------------------------------------------- /etc/setup.d/70services: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright © 2012-2013 Roger Leigh 3 | # 4 | # schroot is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation, either version 3 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # schroot is distributed in the hope that it will be useful, but 10 | # WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program. If not, see 16 | # . 17 | # 18 | ##################################################################### 19 | 20 | # Starts and stops services inside the chroot. 21 | # We start and stop with invoke-rc.d --force, so that normal 22 | # invoke-rc.d use inside the chroot can continue to rely on 23 | # policy-rc.d to function. 24 | # Set setup.services=service1,service2 in schroot.conf 25 | # Services are started in the specified order. 26 | # Services are stopped in the reverse order of starting. 27 | 28 | set -e 29 | 30 | . "$SETUP_DATA_DIR/common-data" 31 | . "$SETUP_DATA_DIR/common-functions" 32 | . "$SETUP_DATA_DIR/common-config" 33 | 34 | if [ $STAGE = "setup-start" ] || [ $STAGE = "setup-recover" ]; then 35 | 36 | info "Starting services" 37 | 38 | SETUP_SERVICES=$(echo "$SETUP_SERVICES" | tr ',' '\n') 39 | 40 | for service in $SETUP_SERVICES; do 41 | chroot "$CHROOT_PATH" /usr/sbin/invoke-rc.d --force "$service" start 42 | done 43 | 44 | elif [ $STAGE = "setup-stop" ]; then 45 | 46 | info "Stopping services" 47 | 48 | SETUP_SERVICES=$(echo "$SETUP_SERVICES" | tr ',' '\n' | tac) 49 | 50 | for service in $SETUP_SERVICES; do 51 | chroot "$CHROOT_PATH" /usr/sbin/invoke-rc.d --force "$service" stop || true 52 | done 53 | fi 54 | 55 | -------------------------------------------------------------------------------- /etc/setup.d/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(setup_data 20 | common-config 21 | common-data 22 | common-functions) 23 | 24 | set(setup_scripts 25 | 00check 26 | 05file 27 | 05btrfs 28 | 05union 29 | 10mount 30 | 15binfmt 31 | 15killprocs 32 | 20copyfiles 33 | 20nssdatabases 34 | 50chrootname 35 | 70services) 36 | 37 | install(FILES ${setup_data} 38 | DESTINATION ${SCHROOT_SETUP_DATA_DIR}) 39 | 40 | install(PROGRAMS ${setup_scripts} 41 | DESTINATION ${SCHROOT_CONF_SETUP_D}) 42 | 43 | install(CODE " 44 | message(STATUS \"Symlinking: \$ENV{DESTDIR}${SCHROOT_CONF_SETUP_D}/99check\") 45 | execute_process(COMMAND ln -sf 00check \$ENV{DESTDIR}${SCHROOT_CONF_SETUP_D}/99check) 46 | ") 47 | -------------------------------------------------------------------------------- /etc/setup.d/common-config: -------------------------------------------------------------------------------- 1 | # Copyright © 2012-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | # Common configuration for use in schroot setup scripts 20 | 21 | # Source setup.config if set 22 | if [ -n "${SETUP_CONFIG}" ]; then 23 | SETUP_CONFIG="${SYSCONF_DIR}/${SETUP_CONFIG}" 24 | if [ -f "$SETUP_CONFIG" ]; then 25 | . "$SETUP_CONFIG" 26 | fi 27 | fi 28 | # Source script-config if set. If the file is no longer present 29 | # (likely for upgrades), then set the defaults here. 30 | if [ -n "$CHROOT_SCRIPT_CONFIG" ]; then 31 | FSTAB="$(dirname "$CHROOT_SCRIPT_CONFIG")/fstab" 32 | COPYFILES="$(dirname "$CHROOT_SCRIPT_CONFIG")/copyfiles" 33 | NSSDATABASES="$(dirname "$CHROOT_SCRIPT_CONFIG")/nssdatabases" 34 | if [ -f "$CHROOT_SCRIPT_CONFIG" ]; then 35 | . "$CHROOT_SCRIPT_CONFIG" 36 | fi 37 | fi 38 | 39 | # Set absolute paths 40 | if [ -n "${SETUP_FSTAB}" ]; then 41 | SETUP_FSTAB="${SYSCONF_DIR}/${SETUP_FSTAB}" 42 | fi 43 | if [ -n "${SETUP_COPYFILES}" ]; then 44 | SETUP_COPYFILES="${SYSCONF_DIR}/${SETUP_COPYFILES}" 45 | fi 46 | if [ -n "${SETUP_NSSDATABASES}" ]; then 47 | SETUP_NSSDATABASES="${SYSCONF_DIR}/${SETUP_NSSDATABASES}" 48 | fi 49 | 50 | # For backward compatibility with old script-config files. This 51 | # overrides the new profile userdata settings. It will be removed in 52 | # 1.7.x 53 | if [ -n "$FSTAB" ]; then 54 | SETUP_FSTAB="$FSTAB" 55 | fi 56 | if [ -n "$COPYFILES" ]; then 57 | SETUP_COPYFILES="$COPYFILES" 58 | fi 59 | if [ -n "$NSSDATABASES" ]; then 60 | SETUP_NSSDATABASES="$NSSDATABASES" 61 | fi 62 | -------------------------------------------------------------------------------- /etc/setup.d/common-data: -------------------------------------------------------------------------------- 1 | # Copyright © 2010-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | # Common data for use in schroot setup scripts 20 | 21 | # Script arguments 22 | STAGE="$1" 23 | STATUS="$2" 24 | 25 | 26 | # FreeBSD uses character devices in place of block devices 27 | case "$(uname -s)" in 28 | *FreeBSD) : 29 | DEVTYPE="-c" 30 | ;; 31 | *): 32 | DEVTYPE="-b" 33 | ;; 34 | esac 35 | -------------------------------------------------------------------------------- /etc/setup.d/common-functions: -------------------------------------------------------------------------------- 1 | # Copyright © 2010-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | # Common functions for use in schroot setup scripts 20 | 21 | # Log an informational message 22 | # $1: The message 23 | info() 24 | { 25 | if [ "$VERBOSE" = "verbose" ]; then 26 | echo "$1" 27 | fi 28 | return 0 29 | } 30 | 31 | # Log warning message 32 | # $1: The message 33 | warn() 34 | { 35 | echo "warning: $1" 1>&2 36 | return 0 37 | } 38 | 39 | # Log an error message 40 | # $1: The message 41 | error() 42 | { 43 | echo "error: $1" 1>&2 44 | return 0 45 | } 46 | 47 | # Log an error message 48 | # $1: The message 49 | fatal() 50 | { 51 | echo "error: $1" 1>&2 52 | exit 1 53 | } 54 | -------------------------------------------------------------------------------- /lib/bin-common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(bin_common_sources 20 | main.h 21 | main.cc 22 | option-action.h 23 | option-action.cc 24 | options.h 25 | options.cc 26 | run.h) 27 | 28 | add_library(bin-common STATIC ${bin_common_sources}) 29 | target_compile_features(bin-common 30 | INTERFACE cxx_generalized_initializers cxx_nullptr 31 | PUBLIC cxx_generalized_initializers cxx_nullptr) 32 | target_link_libraries(bin-common ${Boost_PROGRAM_OPTIONS_LIBRARY_RELEASE}) 33 | -------------------------------------------------------------------------------- /lib/bin-common/option-action.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | using std::endl; 32 | using boost::format; 33 | using schroot::_; 34 | namespace opt = boost::program_options; 35 | 36 | namespace bin 37 | { 38 | namespace common 39 | { 40 | 41 | option_action::option_action (): 42 | default_action(), 43 | current_action(), 44 | actions() 45 | { 46 | } 47 | 48 | option_action::~option_action () 49 | { 50 | } 51 | 52 | void 53 | option_action::add (const action_type& action) 54 | { 55 | this->actions.insert(action); 56 | } 57 | 58 | option_action::action_type const& 59 | option_action::get_default () 60 | { 61 | return this->default_action; 62 | } 63 | 64 | void 65 | option_action::set_default (const action_type& action) 66 | { 67 | if (valid(action)) 68 | this->default_action = action; 69 | else 70 | throw bin::common::options::error((format(_("%1%: invalid action")) % action).str()); 71 | } 72 | 73 | option_action::action_type const& 74 | option_action::get () 75 | { 76 | if (this->current_action != "") 77 | return this->current_action; 78 | else 79 | return this->default_action; 80 | } 81 | 82 | void 83 | option_action::set (const action_type& action) 84 | { 85 | if (valid(action)) 86 | { 87 | if (this->current_action == "") 88 | this->current_action = action; 89 | else 90 | throw bin::common::options::error 91 | (_("Only one action may be specified")); 92 | } 93 | else 94 | throw bin::common::options::error((format(_("%1%: invalid action")) % action).str()); 95 | } 96 | 97 | bool 98 | option_action::valid (const action_type& action) 99 | { 100 | return this->actions.find(action) != this->actions.end(); 101 | } 102 | 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /lib/bin-common/run.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef BIN_COMMON_RUN_H 20 | #define BIN_COMMON_RUN_H 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace bin 33 | { 34 | namespace common 35 | { 36 | 37 | /** 38 | * Main routine. 39 | * 40 | * @param argc the number of arguments 41 | * @param argv argument vector 42 | * 43 | * @returns 0 on success, 1 on failure or the exit status of the 44 | * chroot command. 45 | */ 46 | template 47 | static int 48 | run (int argc, 49 | char *argv[]) 50 | { 51 | typedef O options_type; 52 | typedef M main_type; 53 | 54 | try 55 | { 56 | // Set up locale. 57 | try 58 | { 59 | std::locale::global(std::locale("")); 60 | } 61 | catch (const std::runtime_error& e) // Invalid locale 62 | { 63 | std::locale::global(std::locale::classic()); 64 | } 65 | std::cout.imbue(std::locale()); 66 | std::cerr.imbue(std::locale()); 67 | 68 | ::schroot::bindtextdomain (SCHROOT_MESSAGE_CATALOGUE, SCHROOT_LOCALE_DIR); 69 | ::schroot::textdomain (SCHROOT_MESSAGE_CATALOGUE); 70 | 71 | typename options_type::ptr opts(new options_type); 72 | main_type kit(opts); 73 | exit (kit.run(argc, argv)); 74 | } 75 | catch (const std::exception& e) 76 | { 77 | ::schroot::log_exception_error(e); 78 | exit(EXIT_FAILURE); 79 | } 80 | catch (...) 81 | { 82 | ::schroot::log_unknown_exception_error(); 83 | exit(EXIT_FAILURE); 84 | } 85 | } 86 | 87 | } 88 | } 89 | 90 | #endif /* BIN_COMMON_RUN_H */ 91 | 92 | /* 93 | * Local Variables: 94 | * mode:C++ 95 | * End: 96 | */ 97 | -------------------------------------------------------------------------------- /lib/schroot/auth/deny.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_AUTH_DENY_H 20 | #define SCHROOT_AUTH_DENY_H 21 | 22 | #include 23 | 24 | namespace schroot 25 | { 26 | namespace auth 27 | { 28 | 29 | /** 30 | * Deny Authentication handler. 31 | * 32 | * deny handles user authentication, authorisation and session 33 | * management. Unlike auth_pam, it does nothing. All attempts to 34 | * authenticate will fail (deny). 35 | */ 36 | class deny : public auth 37 | { 38 | private: 39 | /** 40 | * The constructor. 41 | * 42 | * @param service_name the PAM service name. This should be a 43 | * hard-coded constant string literal for safety and security. 44 | * This is passed to pam_start() when initialising PAM, and is 45 | * used to load the correct configuration file from /etc/pam.d. 46 | */ 47 | deny (const std::string& service_name); 48 | 49 | public: 50 | /** 51 | * The destructor. 52 | */ 53 | virtual ~deny (); 54 | 55 | /** 56 | * Create an deny object. 57 | * 58 | * @param service_name the PAM service name. This should be a 59 | * hard-coded constant string literal for safety and security. 60 | * This is passed to pam_start() when initialising PAM, and is 61 | * used to load the correct configuration file from /etc/pam.d. 62 | * @returns a shared pointer to the created object. 63 | */ 64 | static auth::ptr 65 | create (const std::string& service_name); 66 | 67 | /** 68 | * Get the PAM environment. This is the environment as set by PAM 69 | * modules. 70 | * 71 | * @returns an environment list. 72 | */ 73 | virtual environment 74 | get_auth_environment () const; 75 | 76 | virtual void 77 | start (); 78 | 79 | virtual void 80 | stop (); 81 | 82 | virtual void 83 | authenticate (status auth_status); 84 | 85 | virtual bool 86 | is_initialised () const; 87 | 88 | protected: 89 | /// Is the serive initialised? 90 | bool initialised; 91 | /// Minimal environment. 92 | environment auth_environment; 93 | }; 94 | 95 | } 96 | } 97 | 98 | #endif /* SCHROOT_AUTH_DENY_H */ 99 | 100 | /* 101 | * Local Variables: 102 | * mode:C++ 103 | * End: 104 | */ 105 | -------------------------------------------------------------------------------- /lib/schroot/auth/pam-conv.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace schroot 24 | { 25 | namespace auth 26 | { 27 | 28 | pam_conv::pam_conv () 29 | { 30 | } 31 | 32 | pam_conv::~pam_conv () 33 | { 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/schroot/auth/pam-message.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace schroot 24 | { 25 | namespace auth 26 | { 27 | 28 | pam_message::pam_message (message_type type, 29 | const std::string& message): 30 | type(type), 31 | message(message), 32 | response() 33 | { 34 | } 35 | 36 | pam_message::~pam_message () 37 | { 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/schroot/auth/pam-message.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_AUTH_PAM_MESSAGE_H 20 | #define SCHROOT_AUTH_PAM_MESSAGE_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace schroot 27 | { 28 | namespace auth 29 | { 30 | 31 | /** 32 | * Authentication messages. 33 | * 34 | * When pam needs to interact with the user, it does this by 35 | * sending a list of pam_message objects to an pam_conv 36 | * conversation object. These messages tell the conversation object 37 | * how to display the message to the user, and if necessary, whether 38 | * or not to ask the user for some input. They also store the 39 | * user's input, if required. 40 | */ 41 | class pam_message 42 | { 43 | public: 44 | /// Message type 45 | enum message_type 46 | { 47 | /// Display a prompt, with no echoing of user input. 48 | MESSAGE_PROMPT_NOECHO = PAM_PROMPT_ECHO_OFF, 49 | /// Display a prompt, echoing user input. 50 | MESSAGE_PROMPT_ECHO = PAM_PROMPT_ECHO_ON, 51 | /// Display an error message. 52 | MESSAGE_ERROR = PAM_ERROR_MSG, 53 | /// Display an informational message. 54 | MESSAGE_INFO = PAM_TEXT_INFO 55 | }; 56 | 57 | /** 58 | * The constructor. 59 | * 60 | * @param type the type of message. 61 | * @param message the message to display. 62 | */ 63 | pam_message (message_type type, 64 | const std::string& message); 65 | 66 | /// The destructor. 67 | virtual ~pam_message (); 68 | 69 | /// The type of message. 70 | message_type type; 71 | /// The message to display. 72 | std::string message; 73 | /// The user's response (if any). 74 | std::string response; 75 | }; 76 | 77 | } 78 | } 79 | 80 | #endif /* SCHROOT_AUTH_PAM_MESSAGE_H */ 81 | 82 | /* 83 | * Local Variables: 84 | * mode:C++ 85 | * End: 86 | */ 87 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/block-device.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_BLOCK_DEVICE_H 20 | #define SCHROOT_CHROOT_FACET_BLOCK_DEVICE_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace schroot 28 | { 29 | namespace chroot 30 | { 31 | namespace facet 32 | { 33 | 34 | /** 35 | * A chroot stored on an unmounted block device. 36 | * 37 | * The device will be mounted on demand. 38 | */ 39 | class block_device : public block_device_base, 40 | public session_setup 41 | { 42 | public: 43 | /// A shared_ptr to a chroot facet object. 44 | typedef std::shared_ptr ptr; 45 | 46 | /// A shared_ptr to a const chroot facet object. 47 | typedef std::shared_ptr const_ptr; 48 | 49 | protected: 50 | /// The constructor. 51 | block_device (); 52 | 53 | /// The copy constructor. 54 | block_device (const block_device& rhs); 55 | 56 | void 57 | set_chroot (chroot& chroot, 58 | bool copy); 59 | 60 | friend class chroot; 61 | 62 | public: 63 | /// The destructor. 64 | virtual ~block_device (); 65 | 66 | virtual std::string const& 67 | get_name () const; 68 | 69 | /** 70 | * Create a chroot facet. 71 | * 72 | * @returns a shared_ptr to the new chroot facet. 73 | */ 74 | static ptr 75 | create (); 76 | 77 | virtual facet::ptr 78 | clone () const; 79 | 80 | virtual void 81 | chroot_session_setup (const chroot& parent, 82 | const std::string& session_id, 83 | const std::string& alias, 84 | const std::string& user, 85 | bool root); 86 | 87 | protected: 88 | virtual void 89 | setup_lock (chroot::setup_type type, 90 | bool lock, 91 | int status); 92 | }; 93 | 94 | } 95 | } 96 | } 97 | 98 | #endif /* SCHROOT_CHROOT_FACET_BLOCK_DEVICE_H */ 99 | 100 | /* 101 | * Local Variables: 102 | * mode:C++ 103 | * End: 104 | */ 105 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/directory-base.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_DIRECTORY_BASE_H 20 | #define SCHROOT_CHROOT_FACET_DIRECTORY_BASE_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace schroot 27 | { 28 | namespace chroot 29 | { 30 | namespace facet 31 | { 32 | 33 | /** 34 | * A base class for chroots located in a local directory. 35 | * 36 | * This class doesn't implement a chroot (get_chroot_type is not 37 | * implemented). plain and directory chroots inherit from this 38 | * class. 39 | * 40 | * Originally plain inherited from the directory chroot, but this 41 | * had to be changed when union support was introduced. As plain 42 | * chroots don't run any setup scripts and basically just call 43 | * 'chroot' on a directory, they can't support union based sessions. 44 | */ 45 | class directory_base : public facet, 46 | public storage 47 | { 48 | public: 49 | /// Exception type. 50 | typedef chroot::error error; 51 | 52 | protected: 53 | /// The constructor. 54 | directory_base (); 55 | 56 | /// The copy constructor. 57 | directory_base (const directory_base& rhs); 58 | 59 | friend class chroot; 60 | 61 | public: 62 | /// The destructor. 63 | virtual ~directory_base (); 64 | 65 | public: 66 | /** 67 | * Get the directory containing the chroot. 68 | * 69 | * @returns the location. 70 | */ 71 | std::string const& 72 | get_directory () const; 73 | 74 | /** 75 | * Set the directory containing the chroot. 76 | * 77 | * @param directory the directory. 78 | */ 79 | void 80 | set_directory (const std::string& directory); 81 | 82 | virtual void 83 | setup_env (environment& env) const; 84 | 85 | protected: 86 | virtual void 87 | get_details (format_detail& detail) const; 88 | 89 | virtual void 90 | get_used_keys (string_list& used_keys) const; 91 | 92 | virtual void 93 | get_keyfile (keyfile& keyfile) const; 94 | 95 | virtual void 96 | set_keyfile (const keyfile& keyfile); 97 | 98 | /// The directory to use. 99 | std::string directory; 100 | }; 101 | 102 | } 103 | } 104 | } 105 | 106 | #endif /* SCHROOT_CHROOT_FACET_DIRECTORY_BASE_H */ 107 | 108 | /* 109 | * Local Variables: 110 | * mode:C++ 111 | * End: 112 | */ 113 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/facet.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | using boost::format; 27 | 28 | namespace schroot 29 | { 30 | namespace chroot 31 | { 32 | namespace facet 33 | { 34 | 35 | facet::facet (): 36 | owner(0) 37 | { 38 | } 39 | 40 | facet::~facet () 41 | { 42 | } 43 | 44 | void 45 | facet::set_chroot (chroot& chroot, 46 | bool copy) 47 | { 48 | this->owner = &chroot; 49 | } 50 | 51 | std::string const& 52 | facet::get_name () const 53 | { 54 | static const std::string name("facet"); 55 | 56 | return name; 57 | } 58 | 59 | void 60 | facet::setup_env (environment& env) const 61 | { 62 | } 63 | 64 | facet::session_flags 65 | facet::get_session_flags () const 66 | { 67 | return SESSION_NOFLAGS; 68 | } 69 | 70 | void 71 | facet::get_details (format_detail& detail) const 72 | { 73 | } 74 | 75 | void 76 | facet::get_used_keys (string_list& used_keys) const 77 | { 78 | } 79 | 80 | void 81 | facet::get_keyfile (keyfile& keyfile) const 82 | { 83 | } 84 | 85 | void 86 | facet::set_keyfile (const keyfile& keyfile) 87 | { 88 | } 89 | 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/factory.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2011-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace schroot 29 | { 30 | namespace chroot 31 | { 32 | namespace facet 33 | { 34 | 35 | factory::factory(const facet_info& info) 36 | { 37 | registered_facets().insert(std::make_pair(info.name, &info)); 38 | } 39 | 40 | factory::~factory() 41 | { 42 | } 43 | 44 | std::ostream& 45 | factory::print_facets(std::ostream& stream) 46 | { 47 | boost::format fmt(" %1$-17s %2%\n"); 48 | 49 | const map_type& facets = registered_facets(); 50 | for (const auto& facet : facets) 51 | stream << fmt % facet.first % gettext(facet.second->description); 52 | 53 | return stream; 54 | } 55 | 56 | facet::ptr 57 | factory::create (const std::string& name) 58 | { 59 | facet::ptr ret; 60 | 61 | const map_type& facets = registered_facets(); 62 | 63 | map_type::const_iterator info = facets.find(name); 64 | if (info == facets.end()) 65 | throw chroot::error(name, chroot::FACET_INVALID); 66 | ret = info->second->create(); 67 | 68 | return ret; 69 | } 70 | 71 | std::vector 72 | factory::create_auto () 73 | { 74 | std::vector ret; 75 | 76 | for (const auto& facet : registered_facets()) 77 | { 78 | if (facet.second->auto_install) 79 | ret.push_back(facet.second->create()); 80 | } 81 | 82 | return ret; 83 | } 84 | 85 | factory::map_type& 86 | factory::registered_facets () 87 | { 88 | static map_type facets; 89 | return facets; 90 | } 91 | 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/factory.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2011-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_FACTORY_H 20 | #define SCHROOT_CHROOT_FACET_FACTORY_H 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace schroot 30 | { 31 | namespace chroot 32 | { 33 | namespace facet 34 | { 35 | 36 | class factory 37 | { 38 | public: 39 | struct facet_info 40 | { 41 | /// Facet name. 42 | std::string name; 43 | /// Facet description. 44 | std::string description; 45 | /// Install in a chroot automatically on chroot creation. 46 | bool auto_install; 47 | /// Function to create an instance of this facet. 48 | facet::ptr (*create)(); 49 | }; 50 | 51 | factory (const facet_info& info); 52 | 53 | ~factory (); 54 | 55 | static std::ostream& 56 | print_facets (std::ostream& stream); 57 | 58 | static facet::ptr 59 | create (const std::string& name); 60 | 61 | static std::vector 62 | create_auto (); 63 | 64 | private: 65 | typedef std::map map_type; 66 | 67 | static map_type& 68 | registered_facets (); 69 | }; 70 | 71 | } 72 | } 73 | } 74 | 75 | #endif /* SCHROOT_CHROOT_FACET_FACTORY_H */ 76 | 77 | /* 78 | * Local Variables: 79 | * mode:C++ 80 | * End: 81 | */ 82 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/personality.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_PERSONALITY_H 20 | #define SCHROOT_CHROOT_FACET_PERSONALITY_H 21 | 22 | #include 23 | #include 24 | 25 | namespace schroot 26 | { 27 | namespace chroot 28 | { 29 | namespace facet 30 | { 31 | 32 | /** 33 | * Chroot support for kernel personalities (execution domains). 34 | */ 35 | class personality : public facet 36 | { 37 | public: 38 | /// A shared_ptr to a chroot facet object. 39 | typedef std::shared_ptr ptr; 40 | 41 | /// A shared_ptr to a const chroot facet object. 42 | typedef std::shared_ptr const_ptr; 43 | 44 | private: 45 | /// The constructor. 46 | personality (); 47 | 48 | public: 49 | /// The destructor. 50 | virtual ~personality (); 51 | 52 | /** 53 | * Create a chroot facet. 54 | * 55 | * @returns a shared_ptr to the new chroot facet. 56 | */ 57 | static ptr 58 | create (); 59 | 60 | virtual facet::ptr 61 | clone () const; 62 | 63 | virtual std::string const& 64 | get_name () const; 65 | 66 | /** 67 | * Get the process execution domain for the chroot. 68 | * 69 | * @returns the personality. 70 | */ 71 | schroot::personality const& 72 | get_persona () const; 73 | 74 | /** 75 | * Set the process execution domain for the chroot. 76 | * 77 | * @param persona the personality. 78 | */ 79 | void 80 | set_persona (const schroot::personality& persona); 81 | 82 | virtual void 83 | get_details (format_detail& detail) const; 84 | 85 | virtual void 86 | get_used_keys (string_list& used_keys) const; 87 | 88 | virtual void 89 | get_keyfile (keyfile& keyfile) const; 90 | 91 | virtual void 92 | set_keyfile (const keyfile& keyfile); 93 | 94 | private: 95 | /// Process execution domain (Linux only). 96 | schroot::personality persona; 97 | }; 98 | 99 | } 100 | } 101 | } 102 | 103 | #endif /* SCHROOT_CHROOT_FACET_PERSONALITY_H */ 104 | 105 | /* 106 | * Local Variables: 107 | * mode:C++ 108 | * End: 109 | */ 110 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/plain.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | 33 | using boost::format; 34 | 35 | namespace schroot 36 | { 37 | namespace chroot 38 | { 39 | namespace facet 40 | { 41 | 42 | namespace 43 | { 44 | 45 | const factory::facet_info plain_info = 46 | { 47 | "plain", 48 | N_("Support for ‘plain’ chroots"), 49 | false, 50 | []() -> facet::ptr { return plain::create(); } 51 | }; 52 | 53 | factory plain_register(plain_info); 54 | 55 | } 56 | 57 | plain::plain (): 58 | directory_base() 59 | { 60 | } 61 | 62 | plain::~plain () 63 | { 64 | } 65 | 66 | plain::plain (const plain& rhs): 67 | directory_base(rhs) 68 | { 69 | } 70 | 71 | std::string const& 72 | plain::get_name () const 73 | { 74 | return plain_info.name; 75 | } 76 | 77 | plain::ptr 78 | plain::create () 79 | { 80 | return ptr(new plain()); 81 | } 82 | 83 | facet::ptr 84 | plain::clone () const 85 | { 86 | return ptr(new plain(*this)); 87 | } 88 | 89 | std::string 90 | plain::get_path () const 91 | { 92 | return get_directory(); 93 | } 94 | 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/plain.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_PLAIN_H 20 | #define SCHROOT_CHROOT_FACET_PLAIN_H 21 | 22 | #include 23 | #include 24 | 25 | namespace schroot 26 | { 27 | namespace chroot 28 | { 29 | namespace facet 30 | { 31 | 32 | /** 33 | * A chroot located in the filesystem (scripts disabled). 34 | * 35 | * This doesn't run any setup scripts and doesn't provide any 36 | * session support. If you need any of these functions, the 37 | * directory chroot type is more suited to your needs. 38 | */ 39 | class plain : public directory_base 40 | { 41 | public: 42 | /// A shared_ptr to a chroot facet object. 43 | typedef std::shared_ptr ptr; 44 | 45 | /// A shared_ptr to a const chroot facet object. 46 | typedef std::shared_ptr const_ptr; 47 | 48 | protected: 49 | /// The constructor. 50 | plain (); 51 | 52 | /// The copy constructor. 53 | plain (const plain& rhs); 54 | 55 | friend class chroot; 56 | 57 | public: 58 | /// The destructor. 59 | virtual ~plain (); 60 | 61 | virtual std::string const& 62 | get_name () const; 63 | 64 | /** 65 | * Create a chroot facet. 66 | * 67 | * @returns a shared_ptr to the new chroot facet. 68 | */ 69 | static ptr 70 | create (); 71 | 72 | virtual facet::ptr 73 | clone () const; 74 | 75 | virtual std::string 76 | get_path () const; 77 | }; 78 | 79 | } 80 | } 81 | } 82 | 83 | #endif /* SCHROOT_CHROOT_FACET_PLAIN_H */ 84 | 85 | /* 86 | * Local Variables: 87 | * mode:C++ 88 | * End: 89 | */ 90 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/session-clonable.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_SESSION_CLONABLE_H 20 | #define SCHROOT_CHROOT_FACET_SESSION_CLONABLE_H 21 | 22 | #include 23 | 24 | namespace schroot 25 | { 26 | namespace chroot 27 | { 28 | namespace facet 29 | { 30 | 31 | /** 32 | * Chroot support for creation of sessions. 33 | * 34 | * A chroot may offer a "session" facet to signal restorable or 35 | * parallel chroot environment usage. This facet allows the chroot 36 | * to support session creation. 37 | */ 38 | class session_clonable : public facet 39 | { 40 | public: 41 | /// A shared_ptr to a chroot facet object. 42 | typedef std::shared_ptr ptr; 43 | 44 | /// A shared_ptr to a const chroot facet object. 45 | typedef std::shared_ptr const_ptr; 46 | 47 | private: 48 | /// The constructor. 49 | session_clonable (); 50 | 51 | public: 52 | /// The destructor. 53 | virtual ~session_clonable (); 54 | 55 | /** 56 | * Create a chroot facet. 57 | * 58 | * @returns a shared_ptr to the new chroot facet. 59 | */ 60 | static ptr 61 | create (); 62 | 63 | virtual facet::ptr 64 | clone () const; 65 | 66 | virtual std::string const& 67 | get_name () const; 68 | 69 | virtual session_flags 70 | get_session_flags () const; 71 | 72 | /** 73 | * Clone a session chroot. 74 | * 75 | * @param session_id the identifier for the new session. 76 | * @param alias the alias used to initially identify the chroot. 77 | * @param user the user creating the session. 78 | * @param root whether or not the user is switching to root. 79 | * @returns a session chroot. 80 | */ 81 | virtual chroot::ptr 82 | clone_session (const std::string& session_id, 83 | const std::string& alias, 84 | const std::string& user, 85 | bool root) const; 86 | }; 87 | 88 | } 89 | } 90 | } 91 | 92 | #endif /* SCHROOT_CHROOT_FACET_SESSION_CLONABLE_H */ 93 | 94 | /* 95 | * Local Variables: 96 | * mode:C++ 97 | * End: 98 | */ 99 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/session-setup.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | namespace schroot 22 | { 23 | namespace chroot 24 | { 25 | namespace facet 26 | { 27 | 28 | session_setup::session_setup () 29 | { 30 | } 31 | 32 | session_setup::~session_setup () 33 | { 34 | } 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/session-setup.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_SESSION_SETUP_H 20 | #define SCHROOT_CHROOT_FACET_SESSION_SETUP_H 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace schroot 28 | { 29 | namespace chroot 30 | { 31 | namespace facet 32 | { 33 | 34 | /** 35 | * Common chroot data. This class contains all of the metadata 36 | * associated with a single chroot, for all chroot types. This is 37 | * the in-core representation of a chroot definition in the 38 | * configuration file, and may be initialised directly from an open 39 | * keyfile. 40 | */ 41 | class session_setup 42 | { 43 | public: 44 | /// A shared_ptr to a chroot session_setup object. 45 | typedef std::shared_ptr ptr; 46 | 47 | /// A shared_ptr to a const chroot session_setup object. 48 | typedef std::shared_ptr const_ptr; 49 | 50 | protected: 51 | /// The constructor. 52 | session_setup (); 53 | 54 | public: 55 | /// The destructor. 56 | virtual ~session_setup (); 57 | 58 | /** 59 | * Set up a newly-cloned session chroot. 60 | * 61 | * @param parent the parent of the cloned chroot. 62 | * @param session_id the identifier (session_id) for the new session. 63 | * @param alias used to initially identify the chroot. 64 | * @param user the user creating the session. 65 | * @param root true if the user has root access, otherwise false. 66 | */ 67 | virtual void 68 | chroot_session_setup (const chroot& parent, 69 | const std::string& session_id, 70 | const std::string& alias, 71 | const std::string& user, 72 | bool root) = 0; 73 | 74 | }; 75 | 76 | } 77 | } 78 | } 79 | 80 | #endif /* SCHROOT_CHROOT_FACET_SESSION_SETUP_H */ 81 | 82 | /* 83 | * Local Variables: 84 | * mode:C++ 85 | * End: 86 | */ 87 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/source-setup.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | namespace schroot 22 | { 23 | namespace chroot 24 | { 25 | namespace facet 26 | { 27 | 28 | source_setup::source_setup () 29 | { 30 | } 31 | 32 | source_setup::~source_setup () 33 | { 34 | } 35 | 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/source-setup.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_SOURCE_SETUP_H 20 | #define SCHROOT_CHROOT_FACET_SOURCE_SETUP_H 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace schroot 28 | { 29 | namespace chroot 30 | { 31 | namespace facet 32 | { 33 | 34 | /** 35 | * Common chroot data. This class contains all of the metadata 36 | * associated with a single chroot, for all chroot types. This is 37 | * the in-core representation of a chroot definition in the 38 | * configuration file, and may be initialised directly from an open 39 | * keyfile. 40 | */ 41 | class source_setup 42 | { 43 | public: 44 | /// A shared_ptr to a chroot source_setup object. 45 | typedef std::shared_ptr ptr; 46 | 47 | /// A shared_ptr to a const chroot source_setup object. 48 | typedef std::shared_ptr const_ptr; 49 | 50 | protected: 51 | /// The constructor. 52 | source_setup (); 53 | 54 | public: 55 | /// The destructor. 56 | virtual ~source_setup (); 57 | 58 | /** 59 | * Set up a newly-cloned source chroot. 60 | * 61 | * @param parent the parent of the cloned chroot. 62 | */ 63 | virtual void 64 | chroot_source_setup (const chroot& parent) = 0; 65 | 66 | }; 67 | 68 | } 69 | } 70 | } 71 | 72 | #endif /* SCHROOT_CHROOT_FACET_SOURCE_SETUP_H */ 73 | 74 | /* 75 | * Local Variables: 76 | * mode:C++ 77 | * End: 78 | */ 79 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/source.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | using boost::format; 28 | using std::endl; 29 | 30 | namespace schroot 31 | { 32 | namespace chroot 33 | { 34 | namespace facet 35 | { 36 | 37 | namespace 38 | { 39 | 40 | const factory::facet_info source_info = 41 | { 42 | "source", 43 | N_("Support for source chroots"), 44 | false, 45 | []() -> facet::ptr { return source::create(); } 46 | }; 47 | 48 | factory source_register(source_info); 49 | 50 | } 51 | 52 | source::source (): 53 | facet() 54 | { 55 | } 56 | 57 | source::~source () 58 | { 59 | } 60 | 61 | source::ptr 62 | source::create () 63 | { 64 | return ptr(new source()); 65 | } 66 | 67 | facet::ptr 68 | source::clone () const 69 | { 70 | return ptr(new source(*this)); 71 | } 72 | 73 | std::string const& 74 | source::get_name () const 75 | { 76 | return source_info.name; 77 | } 78 | 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/source.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_SOURCE_H 20 | #define SCHROOT_CHROOT_FACET_SOURCE_H 21 | 22 | #include 23 | 24 | namespace schroot 25 | { 26 | namespace chroot 27 | { 28 | namespace facet 29 | { 30 | 31 | /** 32 | * Chroot support for clonable sources. 33 | * 34 | * A chroot may offer a "source" facet in addition to its normal 35 | * "session" copy, to allow for maintenence of the source data. 36 | * This facet is installed into source chroots to identify them 37 | * as such, and so modify their session behaviour. 38 | */ 39 | class source : public facet 40 | { 41 | public: 42 | /// A shared_ptr to a chroot facet object. 43 | typedef std::shared_ptr ptr; 44 | 45 | /// A shared_ptr to a const chroot facet object. 46 | typedef std::shared_ptr const_ptr; 47 | 48 | private: 49 | /// The constructor. 50 | source (); 51 | 52 | public: 53 | /// The destructor. 54 | virtual ~source (); 55 | 56 | /** 57 | * Create a chroot facet. 58 | * 59 | * @returns a shared_ptr to the new chroot facet. 60 | */ 61 | static ptr 62 | create (); 63 | 64 | virtual facet::ptr 65 | clone () const; 66 | 67 | virtual std::string const& 68 | get_name () const; 69 | }; 70 | 71 | } 72 | } 73 | } 74 | 75 | #endif /* SCHROOT_CHROOT_FACET_SOURCE_H */ 76 | 77 | /* 78 | * Local Variables: 79 | * mode:C++ 80 | * End: 81 | */ 82 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/storage.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace schroot 24 | { 25 | namespace chroot 26 | { 27 | namespace facet 28 | { 29 | 30 | storage::storage () 31 | { 32 | } 33 | 34 | storage::~storage () 35 | { 36 | } 37 | 38 | void 39 | storage::setup_lock(chroot::setup_type type, 40 | bool lock, 41 | int status) 42 | { 43 | } 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/schroot/chroot/facet/storage.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CHROOT_FACET_STORAGE_H 20 | #define SCHROOT_CHROOT_FACET_STORAGE_H 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace schroot 28 | { 29 | namespace chroot 30 | { 31 | namespace facet 32 | { 33 | 34 | /** 35 | * Chroot storage. This base class is used by all facets 36 | * implementing storage methods, for example directories, LVM 37 | * snapshots, files, etc. 38 | */ 39 | class storage 40 | { 41 | public: 42 | /// A shared_ptr to a chroot storage object. 43 | typedef std::shared_ptr ptr; 44 | 45 | /// A shared_ptr to a const chroot storage object. 46 | typedef std::shared_ptr const_ptr; 47 | 48 | protected: 49 | /// The constructor. 50 | storage(); 51 | 52 | public: 53 | /// The destructor. 54 | virtual ~storage (); 55 | 56 | /** 57 | * Get the path to the chroot. This is the absolute path to the 58 | * root of the chroot, and is typically the same as the mount 59 | * location and location concatenated together, but is overridden 60 | * by the chroot type if required. 61 | * 62 | * @returns the path. 63 | */ 64 | virtual std::string 65 | get_path () const = 0; 66 | 67 | virtual void 68 | setup_lock(chroot::setup_type type, 69 | bool lock, 70 | int status); 71 | 72 | }; 73 | 74 | } 75 | } 76 | } 77 | 78 | #endif /* SCHROOT_CHROOT_FACET_STORAGE_H */ 79 | 80 | /* 81 | * Local Variables: 82 | * mode:C++ 83 | * End: 84 | */ 85 | -------------------------------------------------------------------------------- /lib/schroot/ctty.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace schroot 32 | { 33 | 34 | namespace 35 | { 36 | 37 | /** 38 | * Set close-on-exec flag. An error will be thrown on failure. 39 | * 40 | * @param fd the file descriptor to set. 41 | */ 42 | void 43 | set_cloexec (int fd) 44 | { 45 | int flags = fcntl(fd, F_GETFD); 46 | flags |= FD_CLOEXEC; 47 | if (fcntl(fd, F_SETFD, flags) < 0) 48 | throw ctty_error(CTTY_CLOEXEC, strerror(errno)); 49 | } 50 | 51 | /** 52 | * Open the controlling terminal and return its file descriptor. 53 | * 54 | * @returns the CTTY fd, or -1 on failure. 55 | */ 56 | int 57 | open_ctty () 58 | { 59 | int ctty = open("/dev/tty", O_RDWR|O_NOCTTY); 60 | if (ctty >= 0) 61 | { 62 | set_cloexec(ctty); 63 | } 64 | else 65 | { 66 | ctty = -1; 67 | } 68 | 69 | return ctty; 70 | } 71 | 72 | } 73 | 74 | template<> 75 | error::map_type 76 | error::error_strings = 77 | { 78 | {schroot::CTTY_CLOEXEC, N_("The controlling terminal close-on-execute flag could not be set")}, 79 | {schroot::CTTY_DUP, N_("The controlling terminal file descriptor could not be duplicated")} 80 | }; 81 | 82 | const int CTTY_FILENO(open_ctty()); 83 | 84 | namespace 85 | { 86 | 87 | /** 88 | * Get the file descriptor for cttybuf. An error will be thrown on 89 | * failure. 90 | * 91 | * @returns the CTTY_FILENO file descriptor if there is a CTTY, or a 92 | * duplicated file descriptor for stdin otherwise. 93 | */ 94 | int 95 | cttybuf_fd () 96 | { 97 | int ctty = CTTY_FILENO; 98 | 99 | if (ctty < 0) 100 | { 101 | ctty = dup(STDIN_FILENO); 102 | 103 | if (ctty < 0) 104 | throw ctty_error(CTTY_DUP, strerror(errno)); 105 | 106 | set_cloexec(ctty); 107 | } 108 | 109 | return ctty; 110 | } 111 | 112 | /// A streambuf for cctty. 113 | // boost::iostreams::file_descriptor cttybuf(cttybuf_fd(), close_handle); 114 | 115 | } 116 | 117 | #ifdef BOOST_IOSTREAMS_CLOSE_HANDLE_OLD 118 | fdstream cctty(cttybuf_fd(), true); 119 | #else 120 | fdstream cctty(cttybuf_fd(), boost::iostreams::close_handle); 121 | #endif 122 | 123 | } 124 | -------------------------------------------------------------------------------- /lib/schroot/ctty.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_CTTY_H 20 | #define SCHROOT_CTTY_H 21 | 22 | #include 23 | #include 24 | 25 | namespace schroot 26 | { 27 | 28 | /// Error codes. 29 | enum ctty_error_code 30 | { 31 | /// The controlling terminal close-on-execute flag could not be 32 | /// set. 33 | CTTY_CLOEXEC, 34 | /// The controlling terminal file descriptor could not be 35 | /// duplicated. 36 | CTTY_DUP 37 | }; 38 | 39 | /// Exception type. 40 | typedef parse_error ctty_error; 41 | 42 | /** 43 | * CTTY fd. The fd number of the Controlling TTY, or -1 if not 44 | * available. 45 | */ 46 | extern const int CTTY_FILENO; 47 | 48 | /** 49 | * CTTY stream. A stream to the Controlling TTY, or standard input 50 | * if not available. 51 | */ 52 | extern fdstream cctty; 53 | 54 | } 55 | 56 | #endif /* SCHROOT_CTTY_H */ 57 | 58 | /* 59 | * Local Variables: 60 | * mode:C++ 61 | * End: 62 | */ 63 | -------------------------------------------------------------------------------- /lib/schroot/fdstream.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2011-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_FDSTREAM_H 20 | #define SCHROOT_FDSTREAM_H 21 | 22 | #include 23 | #include 24 | 25 | namespace schroot 26 | { 27 | 28 | // Stream type. 29 | typedef boost::iostreams::stream fdstream; 30 | 31 | // Stream type. 32 | typedef boost::iostreams::stream fdistream; 33 | 34 | // Stream type. 35 | typedef boost::iostreams::stream fdostream; 36 | 37 | } 38 | 39 | #endif /* SCHROOT_FDSTREAM_H */ 40 | 41 | /* 42 | * Local Variables: 43 | * mode:C++ 44 | * End: 45 | */ 46 | -------------------------------------------------------------------------------- /lib/schroot/feature.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2011-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace schroot 27 | { 28 | 29 | feature::feature(const std::string& feature, 30 | const std::string& description) 31 | { 32 | registered_features().insert(std::make_pair(feature, description)); 33 | } 34 | 35 | feature::~feature() 36 | { 37 | } 38 | 39 | std::ostream& 40 | feature::print_features(std::ostream& stream) 41 | { 42 | boost::format fmt(" %1$-12s %2%\n"); 43 | 44 | std::map& features = registered_features(); 45 | for (const auto& feature : features) 46 | stream << fmt % feature.first % gettext(feature.second); 47 | 48 | return stream; 49 | } 50 | 51 | std::map& 52 | feature::registered_features () 53 | { 54 | static std::map features; 55 | return features; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /lib/schroot/feature.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2011-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_FEATURE_H 20 | #define SCHROOT_FEATURE_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace schroot 29 | { 30 | 31 | class feature 32 | { 33 | public: 34 | feature (const std::string& feature, 35 | const std::string& description); 36 | 37 | ~feature (); 38 | 39 | static std::ostream& 40 | print_features (std::ostream& stream); 41 | 42 | private: 43 | static std::map& 44 | registered_features (); 45 | }; 46 | 47 | } 48 | 49 | #endif /* SCHROOT_FEATURE_H */ 50 | 51 | /* 52 | * Local Variables: 53 | * mode:C++ 54 | * End: 55 | */ 56 | -------------------------------------------------------------------------------- /lib/schroot/format-detail.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | namespace schroot 28 | { 29 | 30 | format_detail::format_detail (const std::string& title, 31 | std::locale locale): 32 | title(title), 33 | locale(locale), 34 | items() 35 | { 36 | } 37 | 38 | format_detail::~format_detail () 39 | { 40 | } 41 | 42 | format_detail& 43 | format_detail::add (const std::string& name, 44 | const std::string& value) 45 | { 46 | for (const auto& item : this->items) 47 | { 48 | if (item.first == name) 49 | { 50 | log_debug(DEBUG_WARNING) << "format_detail: name \"" 51 | << name << "\" is already added" 52 | << std::endl; 53 | return *this; 54 | } 55 | } 56 | 57 | this->items.push_back(value_type(name, value)); 58 | log_debug(DEBUG_INFO) << "format_detail: added name \"" 59 | << name << "\"" 60 | << std::endl; 61 | 62 | return *this; 63 | } 64 | 65 | format_detail& 66 | format_detail::add (const std::string& name, 67 | bool value) 68 | { 69 | const char *desc = 0; 70 | if (value) 71 | desc = _("true"); 72 | else 73 | desc = _("false"); 74 | 75 | return add(name, std::string(desc)); 76 | } 77 | 78 | format_detail& 79 | format_detail::add (const std::string& name, 80 | const string_list& value) 81 | { 82 | return add(name, string_list_to_string(value, " ")); 83 | } 84 | 85 | std::string 86 | format_detail::get_title () const 87 | { 88 | // TRANSLATORS: %1% = title of section 89 | // TRANSLATORS: Please format the --- as a continuous line, e.g. U+2500 90 | boost::format fmt(_("─── %1% ───")); 91 | fmt %this->title; 92 | 93 | return fmt.str(); 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /lib/schroot/nostream.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | namespace schroot 22 | { 23 | 24 | nostream cnull; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /lib/schroot/nostream.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_NOSTREAM_H 20 | #define SCHROOT_NOSTREAM_H 21 | 22 | #include 23 | #include 24 | 25 | namespace schroot 26 | { 27 | 28 | /** 29 | * Null stream buffer. This stream buffer acts as a bit-bucket, 30 | * discarding all input. 31 | */ 32 | template > 33 | class basic_nbuf: public std::basic_streambuf 34 | { 35 | /** 36 | * Output buffer. EOF is never returned. 37 | * 38 | * @param c the character to output. 39 | * @returns traits::not_eof is always returned, never traits::eof. 40 | */ 41 | typename traits::int_type 42 | overflow (typename traits::int_type c) 43 | { 44 | return traits::not_eof(c); // indicate success 45 | } 46 | }; 47 | 48 | /** 49 | * Null output stream. This ostream discards all input, because it 50 | * uses a basic_nbuf stream buffer. 51 | */ 52 | template > 53 | class basic_nostream: public std::basic_ostream 54 | { 55 | public: 56 | /// The constructor. 57 | basic_nostream (): 58 | std::basic_ios(&nbuf), 59 | std::basic_ostream(&nbuf) 60 | { 61 | this->init(&nbuf); 62 | } 63 | 64 | private: 65 | /// The stream buffer. 66 | basic_nbuf nbuf; 67 | }; 68 | 69 | /// A null ostream. 70 | typedef basic_nostream nostream; 71 | /// A wide null ostream. 72 | typedef basic_nostream wnostream; 73 | 74 | /// A null ostream. 75 | extern nostream cnull; 76 | 77 | } 78 | 79 | #endif /* SCHROOT_NOSTREAM_H */ 80 | 81 | /* 82 | * Local Variables: 83 | * mode:C++ 84 | * End: 85 | */ 86 | -------------------------------------------------------------------------------- /lib/schroot/parse-value.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | namespace schroot 24 | { 25 | 26 | template<> 27 | error::map_type 28 | error::error_strings = 29 | { 30 | // TRANSLATORS: %1% = value (arbitrary text) 31 | {BAD_VALUE, N_("Could not parse value ‘%1%’")} 32 | }; 33 | 34 | void 35 | parse_value (const std::string& value, 36 | bool& parsed_value) 37 | { 38 | if (value == "true" || value == "yes" || value == "1") 39 | parsed_value = true; 40 | else if (value == "false" || value == "no" || value == "0") 41 | parsed_value = false; 42 | else 43 | { 44 | log_debug(DEBUG_NOTICE) << "parse error" << std::endl; 45 | throw parse_value_error(value, BAD_VALUE); 46 | } 47 | 48 | log_debug(DEBUG_NOTICE) << "value=" << parsed_value << std::endl; 49 | } 50 | 51 | void 52 | parse_value (const std::string& value, 53 | std::string& parsed_value) 54 | { 55 | parsed_value = value; 56 | log_debug(DEBUG_NOTICE) << "value=" << parsed_value << std::endl; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /lib/schroot/parse-value.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef SCHROOT_PARSE_VALUE_H 20 | #define SCHROOT_PARSE_VALUE_H 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace schroot 29 | { 30 | 31 | /// Error codes. 32 | enum parse_value_error_code 33 | { 34 | BAD_VALUE ///< The value could not be parsed. 35 | }; 36 | 37 | /// Exception type. 38 | typedef parse_error parse_value_error; 39 | 40 | /** 41 | * Parse a boolean value. 42 | * @param value the value to parse. 43 | * @param parsed_value the variable to store the parsed value. 44 | * @returns true on success, false on failure. 45 | */ 46 | void 47 | parse_value (const std::string& value, 48 | bool& parsed_value); 49 | 50 | /** 51 | * Parse a string value. 52 | * @param value the value to parse. 53 | * @param parsed_value the variable to store the parsed value. 54 | * @returns true on success, false on failure. 55 | */ 56 | void 57 | parse_value (const std::string& value, 58 | std::string& parsed_value); 59 | 60 | /** 61 | * Parse a value of type T. 62 | * @param value the value to parse. 63 | * @param parsed_value the variable to store the parsed value. 64 | * @returns true on success, false on failure. 65 | */ 66 | template 67 | void 68 | parse_value (const std::string& value, 69 | T& parsed_value) 70 | { 71 | std::istringstream is(value); 72 | is.imbue(std::locale::classic()); 73 | T tmpval; 74 | if (is >> tmpval) 75 | { 76 | parsed_value = tmpval; 77 | log_debug(DEBUG_NOTICE) << "value=" << parsed_value << std::endl; 78 | } 79 | else 80 | { 81 | log_debug(DEBUG_NOTICE) << "parse error" << std::endl; 82 | throw parse_value_error(value, BAD_VALUE); 83 | } 84 | } 85 | 86 | } 87 | 88 | #endif /* SCHROOT_PARSE_VALUE_H */ 89 | 90 | /* 91 | * Local Variables: 92 | * mode:C++ 93 | * End: 94 | */ 95 | -------------------------------------------------------------------------------- /lib/schroot/schroot.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 5 | 6 | Name: schroot 7 | Description: chroot maintenance and session manager 8 | Version: ${GIT_RELEASE_VERSION} 9 | Libs: -L${libdir} -lschroot 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /lib/schroot/schroot.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: schroot 7 | Description: chroot maintenance and session manager 8 | Version: @schroot_version@ 9 | Libs: -L${libdir} -lschroot 10 | Libs.private: @PAM_LIBS@ @BOOST_LIBS@ @LIBINTL@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /lib/schroot/types.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | namespace schroot 25 | { 26 | 27 | const char * 28 | date_base::get_date_format () const 29 | { 30 | // TRANSLATORS: Format string for date representation: 31 | // %d = day (number, e.g. 14) 32 | // %b = month (three letters, e.g. Jul) 33 | // %Y = year (four digits, e.g. 2006) 34 | // If required, any of the standard strftime(3) 35 | // format specifiers may be used instead, as long as 36 | // the day, month and year are clearly displayed in 37 | // the equivalent standard method for your locale. 38 | return _("%d %b %Y"); 39 | } 40 | 41 | const char * 42 | isodate::get_date_format () const 43 | { 44 | return "%Y-%m-%dT%H:%M:%SZ"; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /lib/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(test_sources 20 | testmain.cc) 21 | 22 | if (BUILD_TESTS) 23 | add_library(testmain STATIC ${test_sources}) 24 | target_link_libraries(testmain libschroot ${GTEST_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 25 | endif (BUILD_TESTS) 26 | -------------------------------------------------------------------------------- /lib/test/testmain.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | int 26 | main(int argc, 27 | char *argv[]) 28 | { 29 | #ifdef SCHROOT_DEBUG 30 | schroot::debug_log_level = schroot::DEBUG_NOTICE; 31 | #else 32 | schroot::debug_log_level = schroot::DEBUG_NONE; 33 | #endif 34 | 35 | testing::InitGoogleTest(&argc, argv); 36 | return RUN_ALL_TESTS(); 37 | } 38 | -------------------------------------------------------------------------------- /libexec/listmounts/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(listmounts_sources 20 | main.h 21 | main.cc 22 | options.h 23 | options.cc 24 | listmounts.cc) 25 | 26 | add_executable(listmounts ${listmounts_sources}) 27 | target_link_libraries(listmounts 28 | libschroot 29 | bin-common 30 | ${Intl_LIBRARIES}) 31 | 32 | install(TARGETS listmounts RUNTIME 33 | DESTINATION ${SCHROOT_LIBEXEC_DIR}) 34 | -------------------------------------------------------------------------------- /libexec/listmounts/listmounts.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | using std::endl; 27 | using boost::format; 28 | namespace opt = boost::program_options; 29 | 30 | /** 31 | * Main routine. 32 | * 33 | * @param argc the number of arguments 34 | * @param argv argument vector 35 | * 36 | * @returns 0 on success, 1 on failure or the exit status of the 37 | * chroot command. 38 | */ 39 | int 40 | main (int argc, 41 | char *argv[]) 42 | { 43 | return bin::common::run 44 | (argc, argv); 45 | } 46 | -------------------------------------------------------------------------------- /libexec/listmounts/main.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef LIBEXEC_LISTMOUNTS_MAIN_H 20 | #define LIBEXEC_LISTMOUNTS_MAIN_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | 28 | namespace bin 29 | { 30 | /** 31 | * schroot-listmounts program components 32 | */ 33 | namespace schroot_listmounts 34 | { 35 | 36 | /** 37 | * Frontend for schroot. This class is used to "run" schroot. 38 | */ 39 | class main : public bin::common::main 40 | { 41 | public: 42 | /// Error codes. 43 | enum error_code 44 | { 45 | FIND ///< Failed to find file. 46 | }; 47 | 48 | /// Exception type. 49 | typedef schroot::custom_error error; 50 | 51 | /** 52 | * The constructor. 53 | * 54 | * @param options the command-line options to use. 55 | */ 56 | main (options::ptr& options); 57 | 58 | /// The destructor. 59 | virtual ~main (); 60 | 61 | private: 62 | /** 63 | * List mounts. 64 | */ 65 | virtual void 66 | action_listmounts (); 67 | 68 | protected: 69 | /** 70 | * Run the program. 71 | * 72 | * @returns 0 on success, 1 on failure or the exit status of the 73 | * chroot command. 74 | */ 75 | virtual int 76 | run_impl (); 77 | 78 | private: 79 | /// The program options. 80 | options::ptr opts; 81 | }; 82 | 83 | } 84 | } 85 | 86 | #endif /* LIBEXEC_LISTMOUNTS_MAIN_H */ 87 | 88 | /* 89 | * Local Variables: 90 | * mode:C++ 91 | * End: 92 | */ 93 | -------------------------------------------------------------------------------- /libexec/listmounts/options.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | using std::endl; 32 | using boost::format; 33 | using schroot::_; 34 | namespace opt = boost::program_options; 35 | 36 | namespace bin 37 | { 38 | namespace schroot_listmounts 39 | { 40 | 41 | const options::action_type options::ACTION_LISTMOUNTS ("listmounts"); 42 | 43 | options::options (): 44 | bin::common::options(), 45 | mountpoint(), 46 | mount(_("Mount")) 47 | { 48 | } 49 | 50 | options::~options () 51 | { 52 | } 53 | 54 | void 55 | options::add_options () 56 | { 57 | // Chain up to add basic options. 58 | bin::common::options::add_options(); 59 | 60 | action.add(ACTION_LISTMOUNTS); 61 | action.set_default(ACTION_LISTMOUNTS); 62 | 63 | mount.add_options() 64 | ("mountpoint,m", opt::value(&this->mountpoint), 65 | _("Mountpoint to check (full path)")); 66 | } 67 | 68 | void 69 | options::add_option_groups () 70 | { 71 | // Chain up to add basic option groups. 72 | bin::common::options::add_option_groups(); 73 | 74 | #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD 75 | if (!mount.options().empty()) 76 | #else 77 | if (!mount.primary_keys().empty()) 78 | #endif 79 | { 80 | visible.add(mount); 81 | global.add(mount); 82 | } 83 | } 84 | 85 | void 86 | options::check_options () 87 | { 88 | // Chain up to check basic options. 89 | bin::common::options::check_options(); 90 | 91 | if (this->action == ACTION_LISTMOUNTS && 92 | this->mountpoint.empty()) 93 | throw error(_("No mount point specified")); 94 | } 95 | 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /libexec/listmounts/options.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef LIBEXEC_LISTMOUNTS_OPTIONS_H 20 | #define LIBEXEC_LISTMOUNTS_OPTIONS_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace bin 27 | { 28 | namespace schroot_listmounts 29 | { 30 | 31 | /** 32 | * schroot-listmounts command-line options. 33 | */ 34 | class options : public bin::common::options 35 | { 36 | public: 37 | /// A shared_ptr to an options object. 38 | typedef std::shared_ptr ptr; 39 | 40 | /// Begin, run and end a session. 41 | static const action_type ACTION_LISTMOUNTS; 42 | 43 | /// The constructor. 44 | options (); 45 | 46 | /// The destructor. 47 | virtual ~options (); 48 | 49 | /// The mountpoint to check. 50 | std::string mountpoint; 51 | 52 | protected: 53 | virtual void 54 | add_options (); 55 | 56 | virtual void 57 | add_option_groups (); 58 | 59 | virtual void 60 | check_options (); 61 | 62 | /// Mount options group. 63 | boost::program_options::options_description mount; 64 | }; 65 | 66 | } 67 | } 68 | 69 | #endif /* LIBEXEC_LISTMOUNTS_OPTIONS_H */ 70 | 71 | /* 72 | * Local Variables: 73 | * mode:C++ 74 | * End: 75 | */ 76 | -------------------------------------------------------------------------------- /libexec/mount/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | set(mount_sources 20 | main.h 21 | main.cc 22 | options.h 23 | options.cc 24 | mount.cc) 25 | 26 | add_executable(mount ${mount_sources}) 27 | target_link_libraries(mount libschroot bin-common 28 | ${Boost_FILESYSTEM_LIBRARY_RELEASE} 29 | ${Boost_SYSTEM_LIBRARY_RELEASE} 30 | ${Intl_LIBRARIES}) 31 | 32 | install(TARGETS mount RUNTIME 33 | DESTINATION ${SCHROOT_LIBEXEC_DIR}) 34 | -------------------------------------------------------------------------------- /libexec/mount/mount.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | using std::endl; 27 | using boost::format; 28 | namespace opt = boost::program_options; 29 | 30 | /** 31 | * Main routine. 32 | * 33 | * @param argc the number of arguments 34 | * @param argv argument vector 35 | * 36 | * @returns 0 on success, 1 on failure or the exit status of the 37 | * chroot command. 38 | */ 39 | int 40 | main (int argc, 41 | char *argv[]) 42 | { 43 | return bin::common::run 44 | (argc, argv); 45 | } 46 | -------------------------------------------------------------------------------- /libexec/mount/options.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | using std::endl; 33 | using boost::format; 34 | using schroot::_; 35 | namespace opt = boost::program_options; 36 | 37 | namespace bin 38 | { 39 | namespace schroot_mount 40 | { 41 | 42 | const options::action_type options::ACTION_MOUNT ("mount"); 43 | 44 | options::options (): 45 | bin::common::options(), 46 | dry_run(false), 47 | fstab(), 48 | mountpoint(), 49 | mount(_("Mount")) 50 | { 51 | } 52 | 53 | options::~options () 54 | { 55 | } 56 | 57 | void 58 | options::add_options () 59 | { 60 | // Chain up to add basic options. 61 | bin::common::options::add_options(); 62 | 63 | action.add(ACTION_MOUNT); 64 | action.set_default(ACTION_MOUNT); 65 | 66 | 67 | mount.add_options() 68 | ("dry-run,d", 69 | _("Perform a simulation of actions which would be taken")) 70 | ("fstab,f", opt::value(&this->fstab), 71 | _("fstab file to read (full path)")) 72 | ("mountpoint,m", opt::value(&this->mountpoint), 73 | _("Mountpoint to check (full path)")); 74 | } 75 | 76 | void 77 | options::add_option_groups () 78 | { 79 | // Chain up to add basic option groups. 80 | bin::common::options::add_option_groups(); 81 | 82 | #ifndef BOOST_PROGRAM_OPTIONS_DESCRIPTION_OLD 83 | if (!mount.options().empty()) 84 | #else 85 | if (!mount.primary_keys().empty()) 86 | #endif 87 | { 88 | visible.add(mount); 89 | global.add(mount); 90 | } 91 | } 92 | 93 | void 94 | options::check_options () 95 | { 96 | // Chain up to check basic options. 97 | bin::common::options::check_options(); 98 | 99 | if (vm.count("dry-run")) 100 | this->dry_run = true; 101 | 102 | this->mountpoint = schroot::normalname(this->mountpoint); 103 | 104 | if (this->action == ACTION_MOUNT && 105 | this->mountpoint.empty()) 106 | throw error(_("No mount point specified")); 107 | } 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /libexec/mount/options.h: -------------------------------------------------------------------------------- 1 | /* Copyright © 2005-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #ifndef LIBEXEC_MOUNT_OPTIONS_H 20 | #define LIBEXEC_MOUNT_OPTIONS_H 21 | 22 | #include 23 | 24 | #include 25 | 26 | namespace bin 27 | { 28 | namespace schroot_mount 29 | { 30 | 31 | /** 32 | * schroot-mount command-line options. 33 | */ 34 | class options : public bin::common::options 35 | { 36 | public: 37 | /// A shared_ptr to an options object. 38 | typedef std::shared_ptr ptr; 39 | 40 | /// Begin, run and end a session. 41 | static const action_type ACTION_MOUNT; 42 | 43 | /// The constructor. 44 | options (); 45 | 46 | /// The destructor. 47 | virtual ~options (); 48 | 49 | /// Dry run. 50 | bool dry_run; 51 | 52 | /// The fstab to read. 53 | std::string fstab; 54 | 55 | /// The mountpoint to check. 56 | std::string mountpoint; 57 | 58 | protected: 59 | virtual void 60 | add_options (); 61 | 62 | virtual void 63 | add_option_groups (); 64 | 65 | virtual void 66 | check_options (); 67 | 68 | /// Mount options group. 69 | boost::program_options::options_description mount; 70 | }; 71 | 72 | } 73 | } 74 | 75 | #endif /* LIBEXEC_MOUNT_OPTIONS_H */ 76 | 77 | /* 78 | * Local Variables: 79 | * mode:C++ 80 | * End: 81 | */ 82 | -------------------------------------------------------------------------------- /man/add/addendum.template: -------------------------------------------------------------------------------- 1 | PO4A-HEADER:mode=after;position=^\.SH "SEE ALSO";beginboundary=^\.SH 2 | .SH TRANSLATOR(S) 3 | This manpage has been translated by TRANSLATOR NAME on TRANSLATION 4 | DATE. 5 | 6 | If you find any mistake in this translation, please send an e-mail to the 7 | translator or to the 8 | .nh 9 | <\fIdebian\-l10n\-LANGUAGE@lists.debian.org\fR>, 10 | .hy 11 | mailing-list. 12 | 13 | # Note to translators: 14 | # Please translate this text in a file called language_code.add 15 | # The addendum MUST use the same encoding as your po file 16 | # Feel free to adapt the text at your convenience. 17 | # Do not forget to translate "SEE ALSO" and "TRANSLATOR(S)" 18 | # The "SEE ALSO" part in the header must be *exactly* the same translation 19 | # as the one in your xx.po file. 20 | # Do not include this comment in your addendum (i.e. all lines starting 21 | # with a #). 22 | # See po4a(7) for further information. 23 | -------------------------------------------------------------------------------- /man/add/fr.add: -------------------------------------------------------------------------------- 1 | PO4A-HEADER:mode=after;position=^\.SH "VOIR AUSSI";beginboundary=^FakePo4aBoundary 2 | 3 | .SH TRADUCTION 4 | Ce document est une traduction, réalisée par Thomas Blein le 5 | 30 mai 2012. 6 | 7 | L'équipe de traduction a fait le maximum pour réaliser une adaptation 8 | française de qualité. 9 | 10 | La version anglaise de ce document est toujours consultable 11 | en ajoutant l'option «\ \-L C\ » à la commande \fBman\fR. 12 | 13 | N'hésitez pas à signaler à l'auteur ou à la liste de traduction 14 | .nh 15 | <\fIdebian\-l10n\-french@lists.debian.org\fR>, 16 | .hy 17 | selon le cas, toute erreur dans cette page de manuel. 18 | -------------------------------------------------------------------------------- /man/authors.man: -------------------------------------------------------------------------------- 1 | .SH AUTHORS 2 | Roger Leigh. 3 | -------------------------------------------------------------------------------- /man/config.man.cmake: -------------------------------------------------------------------------------- 1 | .ds RELEASE_DATE ${RELEASE_DATE_SHORT} 2 | .ds VERSION ${GIT_RELEASE_VERSION} 3 | .ds SCHROOT_LIBEXEC_DIR ${SCHROOT_LIBEXEC_DIR} 4 | .ds SCHROOT_MOUNT_DIR ${SCHROOT_MOUNT_DIR} 5 | .ds SCHROOT_SESSION_DIR ${SCHROOT_SESSION_DIR} 6 | .ds SCHROOT_FILE_UNPACK_DIR ${SCHROOT_FILE_UNPACK_DIR} 7 | .ds SCHROOT_OVERLAY_DIR ${SCHROOT_OVERLAY_DIR} 8 | .ds SCHROOT_UNDERLAY_DIR ${SCHROOT_UNDERLAY_DIR} 9 | .ds SCHROOT_SYSCONF_DIR ${SCHROOT_SYSCONF_DIR} 10 | .ds SCHROOT_CONF ${SCHROOT_CONF} 11 | .ds SCHROOT_CONF_CHROOT_D ${SCHROOT_CONF_CHROOT_D} 12 | .ds SCHROOT_CONF_SETUP_D ${SCHROOT_CONF_SETUP_D} 13 | .ds SCHROOT_DATA_DIR ${SCHROOT_DATA_DIR} 14 | .ds SCHROOT_SETUP_DATA_DIR ${SCHROOT_SETUP_DATA_DIR} 15 | .ds SCHROOT_LOCALE_DIR ${SCHROOT_LOCALE_DIR} 16 | .ds PACKAGE_LOCALE_DIR ${SCHROOT_LOCALE_DIR} 17 | .ds PROGRAM schroot 18 | -------------------------------------------------------------------------------- /man/copyright.man: -------------------------------------------------------------------------------- 1 | .SH COPYRIGHT 2 | Copyright \(co 2005\-2013 Roger Leigh \f[CR]\fP 3 | .PP 4 | \fB\*[PROGRAM]\fP is free software: you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License as 6 | published by the Free Software Foundation, either version 3 of the 7 | License, or (at your option) any later version. 8 | -------------------------------------------------------------------------------- /man/examples/conf-chroots.man: -------------------------------------------------------------------------------- 1 | # Sample configuration 2 | 3 | [sid] 4 | type=plain 5 | description=Debian unstable 6 | description[fr_FR]=Debian instable 7 | directory=/srv/chroot/sid 8 | priority=3 9 | users=jim 10 | groups=sbuild 11 | root\-users=rleigh 12 | aliases=unstable,default 13 | 14 | [etch] 15 | type=block\-device 16 | description=Debian testing (32\-bit) 17 | priority=2 18 | groups=users 19 | #groups=sbuild\-security 20 | aliases=testing 21 | device=/dev/hda_vg/etch_chroot 22 | mount\-options=\-o atime 23 | personality=linux32 24 | 25 | [sid\-file] 26 | type=file 27 | description=Debian sid file\-based chroot 28 | priority=3 29 | groups=sbuild 30 | file=/srv/chroots/sid.tar.gz 31 | 32 | [sid\-snapshot] 33 | type=btrfs\-snapshot 34 | description=Debian unstable LVM snapshot 35 | priority=3 36 | groups=sbuild 37 | users=rleigh 38 | source\-root\-users=rleigh 39 | source\-root\-groups=admin 40 | btrfs\-source\-subvolume=/srv/chroots/sid-snap 41 | btrfs\-snapshot\-directory=/srv/chroots/snapshots 42 | -------------------------------------------------------------------------------- /man/examples/conf-userdata-env.man: -------------------------------------------------------------------------------- 1 | DEBIAN_APT_UPDATE=true 2 | DEBIAN_DISTRIBUTION=unstable 3 | -------------------------------------------------------------------------------- /man/examples/conf-userdata.man: -------------------------------------------------------------------------------- 1 | debian.apt-update=true 2 | debian.distribution=unstable 3 | -------------------------------------------------------------------------------- /man/examples/faq-git-clone.man: -------------------------------------------------------------------------------- 1 | % \f[CB]git clone https://github.com/codelibre-net/schroot.git\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-rm-session-config.man: -------------------------------------------------------------------------------- 1 | %\ \f[CB]rm\ \*[SCHROOT_SESSION_DIR]/my\-session\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-rm-session-mounted-fs.man: -------------------------------------------------------------------------------- 1 | %\ \f[CB]\*[SCHROOT_LIBEXEC_DIR]/schroot\-listmounts\ \-m\ \\ 2 | \*[SCHROOT_MOUNT_DIR]/my\-session\fP\[CR] 3 | -------------------------------------------------------------------------------- /man/examples/faq-session-auto.man: -------------------------------------------------------------------------------- 1 | %\ \f[CB]schroot\ \-c squeeze \-\- command\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-session-create1.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-begin\-session \-c squeeze\fP\[CR] 2 | squeeze\-57a69547\-e014\-4f5d\-a98b\-f4f35a005307 3 | -------------------------------------------------------------------------------- /man/examples/faq-session-create2.man: -------------------------------------------------------------------------------- 1 | % \f[CB]SESSION=$(schroot \-\-begin\-session \-c squeeze)\fP\[CR] 2 | % \f[CB]echo $SESSION\fP\[CR] 3 | squeeze\-57a69547\-e014\-4f5d\-a98b\-f4f35a005307 4 | -------------------------------------------------------------------------------- /man/examples/faq-session-end1.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-end\-session \-c squeeze\-57a69547\-e014\-4f5d\-a98b\-f4f35a005307\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-session-end2.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-end\-session \-c "$SESSION"\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-session-name.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-begin\-session \-c squeeze \-\-session\-name my\-name\fP\[CR] 2 | my\-name 3 | -------------------------------------------------------------------------------- /man/examples/faq-session-run1.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-run\-session \-c squeeze\-57a69547\-e014\-4f5d\-a98b\-f4f35a005307 \\ 2 | \-\- command1\fP\[CR] 3 | -------------------------------------------------------------------------------- /man/examples/faq-session-run2.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-run\-session \-c "$SESSION" \-\- command1\fP\[CR] 2 | -------------------------------------------------------------------------------- /man/examples/faq-session-run3.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-\-run\-session \-c "$SESSION" \-\- command2\fP\[CR] 2 | % \f[CB]schroot \-\-run\-session \-c "$SESSION" \-\- command3\fP\[CR] 3 | % \f[CB]schroot \-\-run\-session \-c "$SESSION" \-\- command4\fP\[CR] 4 | -------------------------------------------------------------------------------- /man/examples/schroot-command.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-c sid /bin/ls\fP\[CR] 2 | [sid chroot] Running command: \[lq]/bin/ls\[rq] 3 | CVS sbuild\-chroot.c sbuild\-session.h schroot.conf.5 4 | Makefile sbuild\-chroot.h schroot.1 schroot.conf.5.in 5 | Makefile.am sbuild\-config.c schroot.1.in 6 | Makefile.in sbuild\-config.h schroot.c 7 | pam sbuild\-session.c schroot.conf 8 | % \f[CB]schroot \-c sid \-\- ls \-1 | head \-n 5\fP\[CR] 9 | [sid chroot] Running command: \[lq]ls \-1\[rq] 10 | ABOUT\-NLS 11 | AUTHORS 12 | COPYING 13 | ChangeLog 14 | INSTALL 15 | -------------------------------------------------------------------------------- /man/examples/schroot-info.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-i \-c sid\fP\[CR] 2 | \[em]\[em]\[em] Chroot \[em]\[em]\[em] 3 | Name sid 4 | Description Debian sid (unstable) 5 | Type plain 6 | Priority 3 7 | Users rleigh 8 | Groups sbuild 9 | Root Users 10 | Root Groups sbuild 11 | Aliases unstable unstable\-sbuild unstable\-p 12 | owerpc\-sbuild 13 | Environment Filter ^(BASH_ENV|CDPATH|ENV|HOSTALIASES|I\\ 14 | FS|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMA\\ 15 | IN|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TE\\ 16 | RMPATH)$ 17 | Run Setup Scripts true 18 | Script Configuration script\-defaults 19 | Session Managed true 20 | Personality linux32 21 | Location /srv/chroot/sid 22 | -------------------------------------------------------------------------------- /man/examples/schroot-list.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-l\fP\[CR] 2 | chroot:default 3 | chroot:etch 4 | chroot:sid 5 | chroot:testing 6 | chroot:unstable 7 | -------------------------------------------------------------------------------- /man/examples/schroot-session-chrootinfo.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-i \-c sid\-snap\fP\[CR] 2 | \[em]\[em]\[em] Chroot \[em]\[em]\[em] 3 | Name sid\-snap 4 | Description Debian sid snapshot 5 | Type lvm\-snapshot 6 | Priority 3 7 | Users maks rleigh 8 | Groups sbuild 9 | Root Users 10 | Root Groups root sbuild 11 | Aliases 12 | Environment Filter ^(BASH_ENV|CDPATH|ENV|HOSTALIASES|I\\ 13 | FS|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMA\\ 14 | IN|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TE\\ 15 | RMPATH)$ 16 | Run Setup Scripts true 17 | Script Configuration script\-defaults 18 | Session Managed true 19 | Personality linux 20 | Device /dev/hda_vg/sid_chroot 21 | Mount Options \-o atime,async,user_xattr 22 | Source Users 23 | Source Groups root rleigh 24 | Source Root Users 25 | Source Root Groups root rleigh 26 | LVM Snapshot Options \-\-size 2G \-c 128 27 | -------------------------------------------------------------------------------- /man/examples/schroot-session-create1.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-b \-c sid\-snap\fP\[CR] 2 | sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f 3 | -------------------------------------------------------------------------------- /man/examples/schroot-session-create2.man: -------------------------------------------------------------------------------- 1 | % \f[CB]SESSION=$(schroot \-b \-c sid\-snap)\fP\[CR] 2 | % \f[CB]echo $SESSION\fP\[CR] 3 | sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f 4 | -------------------------------------------------------------------------------- /man/examples/schroot-session-createname.man: -------------------------------------------------------------------------------- 1 | \f[CR]% \f[CB]schroot \-b \-c sid\-snap \-n my\-session\-name\fP\fP\[CR] 2 | \f[CR]my\-session\-name\fP 3 | -------------------------------------------------------------------------------- /man/examples/schroot-session-end.man: -------------------------------------------------------------------------------- 1 | \f[CR]% \f[CB]schroot \-e \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP\fP\[CR] 2 | \f[CR]% \f[CB]schroot \-e \-c $SESSION\fP\fP\[CR] 3 | -------------------------------------------------------------------------------- /man/examples/schroot-session-runcommand.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-r \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f \-\- \\ 2 | uname \-sr\fP\[CR] 3 | I: [sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f chroot] Running \\ 4 | command: \[lq]uname \-sr\[rq] 5 | Linux 2.6.18\-3\-powerpc 6 | % \f[CB]schroot \-r \-c $SESSION \-\- uname \-sr\fP\[CR] 7 | I: [sid\-snap\-fe170af9\-d9be\-4800\-b1bd\-de275858b938 chroot] Running \\ 8 | command: \[lq]uname \-sr\[rq] 9 | Linux 2.6.18\-3\-powerpc 10 | -------------------------------------------------------------------------------- /man/examples/schroot-session-runcommand1.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-r \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f \-\- \\ 2 | uname \-sr\fP\[CR] 3 | I: [sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f chroot] Running \\ 4 | command: \[lq]uname \-sr\[rq] 5 | Linux 2.6.18\-3\-powerpc 6 | % \f[CB]schroot \-r \-c $SESSION \-\- uname \-sr\fP\[CR] 7 | I: [sid\-snap\-fe170af9\-d9be\-4800\-b1bd\-de275858b938 chroot] Running \\ 8 | command: \[lq]uname \-sr\[rq] 9 | Linux 2.6.18\-3\-powerpc 10 | -------------------------------------------------------------------------------- /man/examples/schroot-session-sessioninfo.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-i \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP\[CR] 2 | \[em]\[em]\[em] Session \[em]\[em]\[em] 3 | Name sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d\\ 4 | 4ccc899f0f 5 | Description Debian sid snapshot 6 | Type lvm\-snapshot 7 | Priority 3 8 | Users maks rleigh 9 | Groups sbuild 10 | Root Users 11 | Root Groups root sbuild 12 | Aliases 13 | Environment Filter ^(BASH_ENV|CDPATH|ENV|HOSTALIASES|I\\ 14 | FS|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMA\\ 15 | IN|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TE\\ 16 | RMPATH)$ 17 | Run Setup Scripts true 18 | Script Configuration script\-defaults 19 | Session Managed true 20 | Personality linux 21 | Mount Location /var/lib/schroot/mount/sid\-snap\-461\\ 22 | 95b04\-0893\-49bf\-beb8\-0d4ccc899f0f 23 | Path /var/lib/schroot/mount/sid\-snap\-461\\ 24 | 95b04\-0893\-49bf\-beb8\-0d4ccc899f0f 25 | Mount Device /dev/hda_vg/sid\-snap\-46195b04\-0893\-\\ 26 | 49bf\-beb8\-0d4ccc899f0f 27 | Device /dev/hda_vg/sid_chroot 28 | Mount Options \-o atime,async,user_xattr 29 | Source Users 30 | Source Groups root rleigh 31 | Source Root Users 32 | Source Root Groups root rleigh 33 | LVM Snapshot Device /dev/hda_vg/sid\-snap\-46195b04\-0893\-\\ 34 | 49bf\-beb8\-0d4ccc899f0f 35 | LVM Snapshot Options \-\-size 2G \-c 128 36 | -------------------------------------------------------------------------------- /man/examples/schroot-userswitch.man: -------------------------------------------------------------------------------- 1 | % \f[CB]schroot \-c sid \-u root\fP\[CR] 2 | Password: 3 | [sid chroot] (rleigh\[->]root) Running login shell: \[lq]/bin/bash\[rq] 4 | # 5 | -------------------------------------------------------------------------------- /man/po/LINGUAS: -------------------------------------------------------------------------------- 1 | de 2 | fr 3 | -------------------------------------------------------------------------------- /man/po4a.cfg: -------------------------------------------------------------------------------- 1 | [po_directory] po/ 2 | 3 | [po4a_alias:man] man opt:"-M UTF-8 -L UTF-8" 4 | 5 | [type: man] authors.man $lang:translated/$lang/authors.man 6 | [type: man] copyright.man $lang:translated/$lang/copyright.man 7 | [type: man] schroot.1.man $lang:translated/$lang/schroot.1.man \ 8 | add_$lang:?add/$lang.add 9 | [type: man] schroot-setup.5.man $lang:translated/$lang/schroot-setup.5.man \ 10 | add_$lang:?add/$lang.add 11 | [type: man] schroot.conf.5.man $lang:translated/$lang/schroot.conf.5.man \ 12 | add_$lang:?add/$lang.add 13 | [type: man] schroot-script-config.5.man $lang:translated/$lang/schroot-script-config.5.man \ 14 | add_$lang:?add/$lang.add 15 | [type: man] schroot-faq.7.man $lang:translated/$lang/schroot-faq.7.man \ 16 | add_$lang:?add/$lang.add 17 | 18 | -------------------------------------------------------------------------------- /po/LINGUAS: -------------------------------------------------------------------------------- 1 | cs 2 | da 3 | de 4 | en 5 | eu 6 | fr 7 | it 8 | pt 9 | sv 10 | vi 11 | zh_CN 12 | -------------------------------------------------------------------------------- /po/POTFILES.in: -------------------------------------------------------------------------------- 1 | bin/dchroot-dsa/dchroot-dsa.cc 2 | bin/dchroot-dsa/main.cc 3 | bin/dchroot-dsa/options.cc 4 | bin/dchroot-dsa/session.cc 5 | bin/dchroot/dchroot.cc 6 | bin/dchroot/main.cc 7 | bin/dchroot/options.cc 8 | bin/dchroot/session.cc 9 | bin/schroot/main.cc 10 | bin/schroot/options.cc 11 | bin/schroot/schroot.cc 12 | lib/bin-common/main.cc 13 | lib/bin-common/option-action.cc 14 | lib/bin-common/options.cc 15 | lib/dchroot-common/main.cc 16 | lib/dchroot-common/session.cc 17 | lib/schroot/auth/auth.cc 18 | lib/schroot/auth/deny.cc 19 | lib/schroot/auth/pam-conv-tty.cc 20 | lib/schroot/auth/pam-conv.cc 21 | lib/schroot/auth/pam-message.cc 22 | lib/schroot/auth/pam.cc 23 | lib/schroot/chroot/chroot.cc 24 | lib/schroot/chroot/config.cc 25 | lib/schroot/chroot/facet/block-device-base.cc 26 | lib/schroot/chroot/facet/block-device.cc 27 | lib/schroot/chroot/facet/btrfs-snapshot.cc 28 | lib/schroot/chroot/facet/custom.cc 29 | lib/schroot/chroot/facet/directory-base.cc 30 | lib/schroot/chroot/facet/directory.cc 31 | lib/schroot/chroot/facet/facet.cc 32 | lib/schroot/chroot/facet/factory.cc 33 | lib/schroot/chroot/facet/file.cc 34 | lib/schroot/chroot/facet/fsunion.cc 35 | lib/schroot/chroot/facet/loopback.cc 36 | lib/schroot/chroot/facet/lvm-snapshot.cc 37 | lib/schroot/chroot/facet/mountable.cc 38 | lib/schroot/chroot/facet/personality.cc 39 | lib/schroot/chroot/facet/plain.cc 40 | lib/schroot/chroot/facet/session-clonable.cc 41 | lib/schroot/chroot/facet/session-setup.cc 42 | lib/schroot/chroot/facet/session.cc 43 | lib/schroot/chroot/facet/source-clonable.cc 44 | lib/schroot/chroot/facet/source-setup.cc 45 | lib/schroot/chroot/facet/source.cc 46 | lib/schroot/chroot/facet/storage.cc 47 | lib/schroot/chroot/facet/unshare.cc 48 | lib/schroot/chroot/facet/userdata.cc 49 | lib/schroot/ctty.cc 50 | lib/schroot/environment.cc 51 | lib/schroot/feature.cc 52 | lib/schroot/format-detail.cc 53 | lib/schroot/keyfile-reader.cc 54 | lib/schroot/keyfile-writer.cc 55 | lib/schroot/keyfile.cc 56 | lib/schroot/lock.cc 57 | lib/schroot/log.cc 58 | lib/schroot/mntstream.cc 59 | lib/schroot/nostream.cc 60 | lib/schroot/parse-value.cc 61 | lib/schroot/personality.cc 62 | lib/schroot/run-parts.cc 63 | lib/schroot/session.cc 64 | lib/schroot/types.cc 65 | lib/schroot/util.cc 66 | lib/schroot-common/main.cc 67 | lib/schroot-common/options.cc 68 | libexec/listmounts/listmounts.cc 69 | libexec/listmounts/main.cc 70 | libexec/listmounts/options.cc 71 | libexec/mount/main.cc 72 | libexec/mount/mount.cc 73 | libexec/mount/options.cc 74 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright © 2004-2013 Roger Leigh 2 | # 3 | # schroot is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # schroot is distributed in the hope that it will be useful, but 9 | # WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | # General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program. If not, see 15 | # . 16 | # 17 | ##################################################################### 18 | 19 | include_directories(${GTEST_INCLUDE_DIR} 20 | ${PROJECT_SOURCE_DIR}/bin) 21 | 22 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/schroot) 23 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/schroot/chroot) 24 | file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin-common) 25 | 26 | set(srcdir ${PROJECT_SOURCE_DIR}) 27 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup-test-data 28 | ${CMAKE_CURRENT_BINARY_DIR}/setup-test-data) 29 | 30 | if (BUILD_TESTS) 31 | add_test(NAME setup-test-data 32 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} 33 | COMMAND ${CMAKE_CURRENT_BINARY_DIR}/setup-test-data) 34 | endif (BUILD_TESTS) 35 | 36 | add_subdirectory(schroot) 37 | add_subdirectory(bin-common) 38 | -------------------------------------------------------------------------------- /test/bin-common/option-action.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | using bin::common::option_action; 27 | 28 | 29 | class OptionAction : public ::testing::Test 30 | { 31 | public: 32 | option_action *action; 33 | 34 | void SetUp() 35 | { 36 | action = new option_action; 37 | } 38 | 39 | void TearDown() 40 | { 41 | delete action; 42 | } 43 | 44 | static void 45 | add_examples(option_action& act) 46 | { 47 | act.add("help"); 48 | act.add("version"); 49 | act.add("list"); 50 | act.add("info"); 51 | act.add("config"); 52 | } 53 | }; 54 | 55 | TEST_F(OptionAction, Construct) 56 | { 57 | ASSERT_NO_THROW(option_action act); 58 | } 59 | 60 | TEST_F(OptionAction, Default) 61 | { 62 | add_examples(*action); 63 | EXPECT_EQ(action->get_default(), ""); 64 | EXPECT_EQ(action->get(), ""); 65 | 66 | action->set_default("info"); 67 | EXPECT_EQ(action->get_default(), "info"); 68 | EXPECT_EQ(action->get(), "info"); 69 | } 70 | 71 | TEST_F(OptionAction, DefaultFail) 72 | { 73 | add_examples(*action); 74 | 75 | ASSERT_THROW(action->set_default("invalid"), bin::common::options::error); 76 | } 77 | 78 | TEST_F(OptionAction, Current) 79 | { 80 | add_examples(*action); 81 | 82 | EXPECT_EQ(action->get_default(), ""); 83 | EXPECT_EQ(action->get(), ""); 84 | action->set_default("list"); 85 | 86 | EXPECT_EQ(action->get_default(), "list"); 87 | EXPECT_EQ(action->get(), "list"); 88 | 89 | action->set("config"); 90 | EXPECT_EQ(action->get_default(), "list"); 91 | EXPECT_EQ(action->get(), "config"); 92 | } 93 | 94 | TEST_F(OptionAction, CurrentFail) 95 | { 96 | add_examples(*action); 97 | 98 | ASSERT_THROW(action->set("invalid"), bin::common::options::error); 99 | } 100 | 101 | TEST_F(OptionAction, CurrentFailMultipleSet) 102 | { 103 | add_examples(*action); 104 | 105 | ASSERT_NO_THROW(action->set("list")); 106 | ASSERT_THROW(action->set("info"), bin::common::options::error); 107 | } 108 | 109 | TEST_F(OptionAction, Operators) 110 | { 111 | add_examples(*action); 112 | 113 | *action = "list"; 114 | EXPECT_TRUE(*action == "list"); 115 | EXPECT_FALSE(*action !="list"); 116 | EXPECT_TRUE(*action != "invalid"); 117 | EXPECT_FALSE(*action == "invalid"); 118 | } 119 | 120 | TEST_F(OptionAction, OperatorsFailMultipleSet) 121 | { 122 | add_examples(*action); 123 | 124 | ASSERT_NO_THROW(*action = "list"); 125 | ASSERT_THROW(*action = "config", bin::common::options::error); 126 | } 127 | -------------------------------------------------------------------------------- /test/config-directory-deprecated.ex: -------------------------------------------------------------------------------- 1 | [deprecated] 2 | description=Debian experimental 3 | location=/srv/chroot/experimental 4 | priority=3 5 | groups=sbuild,root 6 | root-groups=root,sbuild 7 | run-setup-scripts=true 8 | run-exec-scripts=true 9 | 10 | -------------------------------------------------------------------------------- /test/config-directory-fail.ex: -------------------------------------------------------------------------------- 1 | [fail] 2 | description=Debian experimental 3 | directory=/srv/chroot/experimental 4 | location=/srv/chroot/experimental 5 | priority=3 6 | groups=sbuild,root 7 | root-groups=root,sbuild 8 | 9 | -------------------------------------------------------------------------------- /test/config-directory-valid.ex: -------------------------------------------------------------------------------- 1 | [valid] 2 | description=Debian experimental 3 | directory=/srv/chroot/experimental 4 | priority=3 5 | groups=sbuild,root 6 | root-groups=root,sbuild 7 | 8 | -------------------------------------------------------------------------------- /test/config.ex1: -------------------------------------------------------------------------------- 1 | # schroot chroot definitions. 2 | # See schroot.conf(5) for complete documentation of the file format. 3 | # 4 | # Please take note that you should not add untrusted users to 5 | # root-groups, because they will essentially have full root access 6 | # to your system. They will only have root access inside the chroot, 7 | # but that's enough to cause malicious damage. 8 | # 9 | # The following lines are examples. Uncomment and alter them to 10 | # customise schroot for your needs. 11 | # 12 | # 13 | #[woody] 14 | #description=Debian woody (oldstable) 15 | #directory=/home/woody-chroot 16 | #groups=sbuild 17 | #aliases=oldstable 18 | 19 | [sid] 20 | type=directory 21 | description=Debian sid (unstable) 22 | directory=/srv/chroot/sid 23 | priority=3 24 | groups=sbuild,root 25 | root-groups=root,sbuild 26 | aliases=unstable,default 27 | 28 | [sid-local] 29 | description=Debian sid (unstable) 30 | #directory=/srv/chroot/sid 31 | priority=3 32 | groups=sbuild,root 33 | root-groups=root,sbuild 34 | directory=/srv/chroot/sid 35 | 36 | #[etch] 37 | #description=Debian etch (testing) 38 | #directory=/srv/chroot/etch 39 | #groups=sbuild-security 40 | #aliases=testing 41 | 42 | [sarge] 43 | description=Debian sarge (stable) 44 | directory=/srv/chroot/sarge 45 | priority=2 46 | groups=sbuild 47 | root-groups=root,sbuild 48 | #root-groups=root 49 | aliases=stable 50 | 51 | [experimental] 52 | description=Debian experimental 53 | directory=/srv/chroot/experimental 54 | priority=3 55 | groups=sbuild,root 56 | root-groups=root,sbuild 57 | 58 | -------------------------------------------------------------------------------- /test/config.ex2/empty: -------------------------------------------------------------------------------- 1 | # This file contains no chroots. 2 | # 3 | -------------------------------------------------------------------------------- /test/config.ex2/experimental: -------------------------------------------------------------------------------- 1 | [experimental] 2 | description=Debian experimental 3 | directory=/srv/chroot/experimental 4 | priority=3 5 | groups=sbuild,root 6 | root-groups=root,sbuild 7 | 8 | -------------------------------------------------------------------------------- /test/config.ex2/file: -------------------------------------------------------------------------------- 1 | [sid-file] 2 | type=file 3 | description=Debian sid snapshot 4 | priority=3 5 | groups=sbuild,root 6 | file=/srv/chroots/sid.tar.gz 7 | -------------------------------------------------------------------------------- /test/config.ex2/sarge: -------------------------------------------------------------------------------- 1 | [sarge] 2 | description=Debian sarge (stable) 3 | directory=/srv/chroot/sarge 4 | priority=2 5 | groups=sbuild 6 | root-groups=root,sbuild 7 | #root-groups=root 8 | aliases=stable 9 | preserve-environment=true -------------------------------------------------------------------------------- /test/config.ex2/sid: -------------------------------------------------------------------------------- 1 | [sid] 2 | type=directory 3 | description=Debian sid (unstable) 4 | directory=/srv/chroot/sid 5 | priority=3 6 | groups=sbuild,root 7 | root-groups=root,sbuild 8 | aliases=unstable,default 9 | message-verbosity=quiet 10 | 11 | [sid-local] 12 | description=Debian sid (unstable) 13 | #directory=/srv/chroot/sid 14 | priority=3 15 | groups=sbuild,root 16 | root-groups=root,sbuild 17 | directory=/srv/chroot/sid 18 | message-verbosity=verbose 19 | preserve-environment=false -------------------------------------------------------------------------------- /test/config.ex2/woody: -------------------------------------------------------------------------------- 1 | [woody] 2 | description=Debian woody (oldstable) 3 | directory=/home/woody-chroot 4 | groups=sbuild 5 | aliases=oldstable 6 | 7 | -------------------------------------------------------------------------------- /test/keyfile.ex1: -------------------------------------------------------------------------------- 1 | # Comment 2 | [group1] 3 | name=Fred Walker 4 | age=32 5 | 6 | [group2] 7 | name=Mary King 8 | age=43 9 | photo=mary.jpeg 10 | -------------------------------------------------------------------------------- /test/run-parts.ex1/10test1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #echo "10test1 $1" >&2 3 | 4 | exit 0 5 | -------------------------------------------------------------------------------- /test/run-parts.ex1/20test2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #echo "20test2 $1" >&2 3 | 4 | if [ "$1" = "fail" ]; then 5 | exit 1 6 | fi 7 | 8 | exit 0 9 | -------------------------------------------------------------------------------- /test/run-parts.ex1/30test3: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #echo "30test3 $1" >&2 3 | 4 | if [ "$1" = "ok" ]; then 5 | exit 0 6 | fi 7 | 8 | exit 1 9 | -------------------------------------------------------------------------------- /test/run-parts.ex3/50invalid: -------------------------------------------------------------------------------- 1 | This file is not executable. 2 | -------------------------------------------------------------------------------- /test/schroot/nostream.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | TEST(NullOstream, Discard) 26 | { 27 | schroot::cnull << "Discard"; 28 | } 29 | -------------------------------------------------------------------------------- /test/schroot/parse-value.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | TEST(ParseValue, Bool) 24 | { 25 | bool result; 26 | 27 | result = false; 28 | schroot::parse_value("true", result); 29 | EXPECT_TRUE(result); 30 | result = false; 31 | schroot::parse_value("yes", result); 32 | EXPECT_TRUE(result); 33 | result = false; 34 | schroot::parse_value("1", result); 35 | EXPECT_TRUE(result); 36 | 37 | result = true; 38 | schroot::parse_value("false", result); 39 | EXPECT_FALSE(result); 40 | result = true; 41 | schroot::parse_value("no", result); 42 | EXPECT_FALSE(result); 43 | result = true; 44 | schroot::parse_value("0", result); 45 | EXPECT_FALSE(result); 46 | } 47 | 48 | TEST(ParseValue, BoolFail) 49 | { 50 | bool result = true; 51 | 52 | EXPECT_THROW(schroot::parse_value("invalid", result), schroot::parse_value_error); 53 | EXPECT_TRUE(result); 54 | } 55 | 56 | TEST(ParseValue, Int) 57 | { 58 | int result = 0; 59 | schroot::parse_value("23", result); 60 | EXPECT_EQ(result, 23); 61 | } 62 | 63 | TEST(ParseValue, IntFail) 64 | { 65 | int result = 22; 66 | 67 | EXPECT_THROW(schroot::parse_value("invalid", result), schroot::parse_value_error); 68 | EXPECT_EQ(result, 22); 69 | } 70 | 71 | TEST(ParseValue, String) 72 | { 73 | std::string result; 74 | 75 | schroot::parse_value("test string", result); 76 | EXPECT_EQ(result, "test string"); 77 | } 78 | -------------------------------------------------------------------------------- /test/schroot/personality.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | TEST(Personality, Construct1) 27 | { 28 | schroot::personality p; 29 | ASSERT_EQ(p.get_name(), "undefined"); 30 | } 31 | 32 | TEST(Personality, Construct2) 33 | { 34 | schroot::personality p("linux"); 35 | ASSERT_EQ(p.get_name(), "linux"); 36 | } 37 | 38 | TEST(Personality, Construct3) 39 | { 40 | ASSERT_THROW(schroot::personality p("invalid_personality"), schroot::personality::error); 41 | } 42 | 43 | TEST(Personality, StreamOutput) 44 | { 45 | schroot::personality p("linux"); 46 | 47 | std::ostringstream os; 48 | os << p; 49 | 50 | ASSERT_EQ(os.str(), "linux"); 51 | } 52 | 53 | TEST(Personality, StreamInput1) 54 | { 55 | schroot::personality p; 56 | std::istringstream is("undefined"); 57 | ASSERT_NO_THROW(is >> p); 58 | ASSERT_EQ(p.get_name(), "undefined"); 59 | } 60 | 61 | TEST(Personality, StreamInput2) 62 | { 63 | schroot::personality p; 64 | std::istringstream is("linux"); 65 | ASSERT_NO_THROW(is >> p); 66 | ASSERT_EQ(p.get_name(), "linux"); 67 | } 68 | 69 | TEST(Personality, StreamInput3) 70 | { 71 | schroot::personality p; 72 | std::istringstream is("invalid_personality"); 73 | ASSERT_THROW(is >> p, schroot::personality::error); 74 | } 75 | 76 | TEST(Personality, Set1) 77 | { 78 | schroot::personality p; 79 | p.set_name("undefined"); 80 | ASSERT_EQ(p.get_name(), "undefined"); 81 | } 82 | 83 | TEST(Personality, Set2) 84 | { 85 | schroot::personality p; 86 | p.set_name("linux"); 87 | ASSERT_EQ(p.get_name(), "linux"); 88 | } 89 | 90 | TEST(Personality, Set3) 91 | { 92 | schroot::personality p; 93 | ASSERT_THROW(p.set_name("invalid_personality"), schroot::personality::error); 94 | } 95 | -------------------------------------------------------------------------------- /test/schroot/regex.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | TEST(Regex, Construct) 27 | { 28 | EXPECT_NO_THROW(schroot::regex r1); 29 | 30 | EXPECT_NO_THROW(schroot::regex r2("foo")); 31 | 32 | std::string p("foo|bar$"); 33 | EXPECT_NO_THROW(schroot::regex r3(p)); 34 | 35 | EXPECT_THROW(schroot::regex r("[foo"), std::regex_error); 36 | } 37 | 38 | TEST(Regex, StreamOutput) 39 | { 40 | schroot::regex r("foo"); 41 | std::ostringstream o; 42 | o << r; 43 | ASSERT_EQ(r.str(),"foo"); 44 | ASSERT_EQ(o.str(),"foo"); 45 | } 46 | 47 | TEST(Regex, StreamInput) 48 | { 49 | schroot::regex r; 50 | std::istringstream i("foo"); 51 | i >> r; 52 | ASSERT_EQ(r.str(),"foo"); 53 | } 54 | 55 | TEST(Regex, Match) 56 | { 57 | schroot::regex r("^[^:/,.][^:/,]*$"); 58 | ASSERT_TRUE(schroot::regex_search("foobar", r)); 59 | ASSERT_FALSE(schroot::regex_search(":fail:", r)); 60 | } 61 | 62 | TEST(Regex, MatchBracket1) 63 | { 64 | schroot::regex r("^[a-z0-9][a-z0-9-]*$"); 65 | ASSERT_TRUE(schroot::regex_search("foobar", r)); 66 | ASSERT_TRUE(schroot::regex_search("a-", r)); 67 | ASSERT_FALSE(schroot::regex_search("-a", r)); 68 | } 69 | 70 | TEST(Regex, MatchBracket2) 71 | { 72 | schroot::regex r("^[a-z0-9][-a-z0-9]*$"); 73 | ASSERT_TRUE(schroot::regex_search("foobar", r)); 74 | ASSERT_TRUE(schroot::regex_search("a-", r)); 75 | ASSERT_FALSE(schroot::regex_search("-a", r)); 76 | } 77 | 78 | TEST(Regex, StreamInputFail) 79 | { 80 | schroot::regex r; 81 | std::istringstream i("([[invalid_regex"); 82 | EXPECT_THROW(i >> r, std::regex_error); 83 | } 84 | -------------------------------------------------------------------------------- /test/schroot/run-parts.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | 32 | extern char **environ; 33 | 34 | class RunParts : public ::testing::Test 35 | { 36 | public: 37 | std::streambuf *saved; 38 | schroot::basic_nbuf *monitor; 39 | 40 | void SetUp() 41 | { 42 | monitor = new schroot::basic_nbuf(); 43 | saved = std::cerr.std::ios::rdbuf(monitor); 44 | } 45 | 46 | void TearDown() 47 | { 48 | std::cerr.std::ios::rdbuf(saved); 49 | delete monitor; 50 | } 51 | }; 52 | 53 | TEST_F(RunParts, Construct) 54 | { 55 | ASSERT_NO_THROW(schroot::run_parts rp(TESTDATADIR "/run-parts.ex1")); 56 | } 57 | 58 | TEST_F(RunParts, ConstructFail) 59 | { 60 | ASSERT_THROW(schroot::run_parts rp(TESTDATADIR "/invalid_dir"), 61 | boost::filesystem::filesystem_error); 62 | } 63 | 64 | TEST_F(RunParts, Run1) 65 | { 66 | schroot::run_parts rp(TESTDATADIR "/run-parts.ex1"); 67 | 68 | int status; 69 | 70 | schroot::string_list command; 71 | schroot::environment env(environ); 72 | 73 | command.push_back("ok"); 74 | status = rp.run(command, env); 75 | ASSERT_EQ(status, EXIT_SUCCESS); 76 | 77 | command.clear(); 78 | command.push_back("fail"); 79 | status = rp.run(command, env); 80 | ASSERT_EQ(status, EXIT_FAILURE); 81 | 82 | command.clear(); 83 | command.push_back("fail2"); 84 | status = rp.run(command, env); 85 | ASSERT_EQ(status, EXIT_FAILURE); 86 | } 87 | 88 | TEST_F(RunParts, Run2) 89 | { 90 | schroot::run_parts rp(TESTDATADIR "/run-parts.ex2"); 91 | 92 | int status; 93 | 94 | schroot::string_list command; 95 | schroot::environment env(environ); 96 | 97 | command.push_back("ok"); 98 | status = rp.run(command, env); 99 | ASSERT_EQ(status, EXIT_SUCCESS); 100 | } 101 | 102 | TEST_F(RunParts, Run3) 103 | { 104 | schroot::run_parts rp(TESTDATADIR "/run-parts.ex3"); 105 | 106 | int status; 107 | 108 | schroot::string_list command; 109 | schroot::environment env(environ); 110 | 111 | command.push_back("ok"); 112 | status = rp.run(command, env); 113 | ASSERT_EQ(status, EXIT_FAILURE); 114 | } 115 | -------------------------------------------------------------------------------- /test/schroot/util.cc: -------------------------------------------------------------------------------- 1 | /* Copyright © 2006-2013 Roger Leigh 2 | * 3 | * schroot is free software: you can redistribute it and/or modify it 4 | * under the terms of the GNU General Public License as published by 5 | * the Free Software Foundation, either version 3 of the License, or 6 | * (at your option) any later version. 7 | * 8 | * schroot is distributed in the hope that it will be useful, but 9 | * WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 | * General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program. If not, see 15 | * . 16 | * 17 | *********************************************************************/ 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | TEST(Util, Basename) 28 | { 29 | ASSERT_EQ(schroot::basename("/usr/bin/perl"), "perl"); 30 | ASSERT_EQ(schroot::basename("/usr/lib"), "lib"); 31 | ASSERT_EQ(schroot::basename("/usr/"), "usr"); 32 | ASSERT_EQ(schroot::basename("usr"), "usr"); 33 | ASSERT_EQ(schroot::basename("/"), "/"); 34 | ASSERT_EQ(schroot::basename("."), "."); 35 | ASSERT_EQ(schroot::basename(".."), ".."); 36 | } 37 | 38 | TEST(Util, Dirname) 39 | { 40 | ASSERT_EQ(schroot::dirname("/usr/bin/perl"), "/usr/bin"); 41 | ASSERT_EQ(schroot::dirname("/usr/lib"), "/usr"); 42 | ASSERT_EQ(schroot::dirname("/usr/"), "/"); 43 | ASSERT_EQ(schroot::dirname("usr"), "."); 44 | ASSERT_EQ(schroot::dirname("/"), "/"); 45 | ASSERT_EQ(schroot::dirname("."), "."); 46 | ASSERT_EQ(schroot::dirname(".."), "."); 47 | } 48 | 49 | TEST(Util, StringListToString) 50 | { 51 | schroot::string_list items; 52 | items.push_back("foo"); 53 | items.push_back("bar"); 54 | items.push_back("baz"); 55 | 56 | ASSERT_EQ(schroot::string_list_to_string(items, "--"), "foo--bar--baz"); 57 | } 58 | 59 | TEST(Util, SplitString) 60 | { 61 | schroot::string_list items = 62 | schroot::split_string("/usr/share/info", "/"); 63 | 64 | ASSERT_EQ(items.size(), 3); 65 | ASSERT_EQ(items[0], "usr"); 66 | ASSERT_EQ(items[1], "share"); 67 | ASSERT_EQ(items[2], "info"); 68 | } 69 | 70 | TEST(Util, FindProgramInPath) 71 | { 72 | std::string path("/usr/local/bin:/usr/bin:/bin"); 73 | ASSERT_EQ(schroot::find_program_in_path("sh", path, ""), "/bin/sh"); 74 | 75 | boost::filesystem::path sed(schroot::find_program_in_path("sed", path, "")); 76 | ASSERT_EQ(boost::filesystem::path("sed"), sed.filename()); 77 | } 78 | -------------------------------------------------------------------------------- /test/setup-test-data: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This script ensures that the test data is owned by root. 3 | 4 | set -e 5 | 6 | rm -rf test/testdata 7 | mkdir test/testdata 8 | cp -r ${srcdir}/test/*.ex* test/testdata 9 | mkdir test/testdata/run-parts.ex2 10 | chown -R root test/testdata 11 | --------------------------------------------------------------------------------