Commit Graph

279 Commits

Author SHA1 Message Date
Chen Linxuan e76692efab chore: bump version to 1.3.3.12-1
Change-Id: Ib0318a84a84fd8fc1ae9dac5987c2bfbd6e644ad
2022-10-28 15:03:58 +08:00
Chen Linxuan 805c64514f feat: use extra_files.txt
Change-Id: Ica2cdbbec3f270ee6898d5a0e75685c8a9f80696
2022-10-28 15:03:32 +08:00
chenlinxuan 3e83ef0491 fix: uab support
* Bring back bundle support
  * Check reader ptr before use it as when working in uab mode, ll-box
    might not have reader at all.
  * More config.json generate handling code.
  * Install ll-box-static to /usr/libexec

Change-Id: Iafc2f5a684cecbce2aeb8aed90f1eed451c165f2
2022-10-28 15:03:32 +08:00
Chen Linxuan f47eb4ae85 format: run clang-format
Change-Id: Ib48dcc1b878cb991a00690cd94bd2b54e7d0866c
2022-10-28 15:03:32 +08:00
huqinghong ecca3c85e6 chore: bump version to 1.3.3.11-1
update version.

Log:
Change-Id: I77cbf3d9016045d36746847015baadc2cec6c3d7
2022-10-27 16:32:32 +08:00
Chen Linxuan 2709ca579b fix: make path->touch() return void
Change-Id: I5dff88ffd7dfd35c1b36fa8d3f489f103f63a3a1
2022-10-27 16:31:43 +08:00
Chen Linxuan 653e7979de fix: fix a bug that box will overwrite some files
We used to use ofstream with io::out to touch a file. It turns out that
this will overwrite file content if there is already something in that
file.

Now we have a new method called `touch` in util::fs::path, which will
check if that file exist.

Change-Id: I1accec8b57c653c4b2ea7b4aa0016b9cf8f51ac6
2022-10-26 19:22:54 +08:00
chenlinxuan 62ab6a173f fix: unblock all signal before exec new process
Process created by fork will inherit blocked signal list. In then third
level ll-box, we block SIGCHLD and SIGTERM for handling them in
signalfd with epoll. So we have to unblock this two signals to let the
application or command we run can recive this signals.

When a process try to start daemon with double fork, it might wait for
the SIGCHLD of first child. If SIGCHLD is blocked, the process wating
for signal will never recive that signal, and keep waiting forever.

Change-Id: Iebc6810560e89849915d0374acedcdbe5866b818
2022-10-24 10:14:23 +08:00
chenhuixing a6b9bf9b81 chore: bump version to 1.3.3.10-1
update verison.

Log:
Change-Id: Ic92bc2db70409ffaaca55cfbdb32921aef1d3584
2022-09-23 11:21:00 +08:00
chenlinxuan 95b657ab0a fix: no need to retry to read
Change-Id: I7cdaa4726057b5526eace3ce10134e2c534972c7
2022-09-22 15:11:12 +08:00
chenlinxuan 68025e3861 chore: bump version to 1.3.3.9-1
Change-Id: Ia9199ac8e2882a46b5c532ca90a9de87dc4ac764
2022-09-22 11:09:56 +08:00
chenlinxuan bb4f4b4d90 feat: log to syslog
Change-Id: I0fad492b17e816c2e0582e9ad2fede62015214b3
2022-09-22 11:03:46 +08:00
chenlinxuan a903b36f51 fix: make all process handle sigterm
Change-Id: Ic14ac3dd0287cd292064831286ff4eaa6afaa173
2022-09-22 10:09:02 +08:00
chenlinxuan 717d62e580 fix: mem leak
Forget to free buffer, check note 14 for more infomation.

Bug: https://pms.uniontech.com/bug-view-126569.html
Change-Id: I4abe5eb0c7442db14574b158095ae1ce6dbe3b6a
2022-09-22 10:08:25 +08:00
Iceyer 9501c51639
feat: static link ll-box
- Use static link ll-box so that the bundle file can run it without
depends
- Add BUILD_STATIC option to CMakeLists.text, default is OFF

Log:
Change-Id: Ica871aa6311e47f4a38c03d2348f049913ea9ee5
2022-09-18 23:01:41 +08:00
chenhuixing 92dde5e3e1 chore: bump version to 1.3.3.7-1
update version.

Log:
Change-Id: Iaf9c8275fdad677ea6d0c641dbced58d4173d8dd
2022-09-06 11:04:43 +08:00
chenlinxuan dba73717d5 fix: ignore EAGAIN
* We should ignore EAGAIN, as noblock socket would return -1 when read
    with no data in it and set errno to EAGAIN, which mean we have to
    retry later.

Change-Id: I84d01bf719214583e22b8566934cd0836f0e3c90
2022-09-05 10:43:34 +08:00
chenlinxuan 48c2308888 fix: handle SIGTERM in child box
We used to ignore any signal expect SIGCHLD, which lead to the ll-box
which waiting to exec command cannot be killed by SIGTERM.

Change-Id: I06802aec86c95133fd0f2c25644ab35394911e45
2022-09-05 10:43:26 +08:00
chenlinxuan 602ed11df7 feat: add PKGBUILD
* copy PKGBUILD from https://wiki.archlinux.org/title/CMake_package_guidelines
  * add some dependencies

  This is just a workround, dependencies list should be consider more
  carefully.

Change-Id: I1c698974746b91551715950162a858746c28d545
2022-08-26 21:45:23 +08:00
chenlinxuan 7b4da48066 feat: disable log by default
* If environment variable not found, we just won't print any log.

Change-Id: If0f71a76fbf3bf7ef83f8f00850f70ec18283360
2022-08-12 09:57:25 +08:00
liujianqiang 2cb993cd4b feat: bump version to 1.3.3.5-1
update version for deepin.

Log:
Change-Id: I3dc51762916506e7aec5ec67c913b438fa597275
2022-08-01 20:52:22 +08:00
liujianqiang 25aa18d837 fix: 升级版本到1.3.3-1
社区版v23预发布版本更新。

Bug: https://pms.uniontech.com/bug-view-151007.html
Log:
Change-Id: I9266532d2f9e2ac8d22ef91b7043d849363b33f5
2022-07-28 15:32:29 +08:00
chenlinxuan 83416e6e48 fix: use right cwd for exec and add log for exec
* We should cd to the "cwd" of argument but not the cwd in oci config
    as they might be different.
  * Add a new info log before exec, to determine whether we has entered
    the container or not.
  * Add a new warning for failed chdir.

Log: Bug fix and add more log.
Change-Id: I5bef3aa4e19ce37cce324f1886db37575a414177
2022-07-21 10:03:13 +08:00
chenlinxuan 0022e90c97 fix(exec): always new pid ns in third layer box
As the 'exec' function is implemented by forking a new child from the
init process. The init process have to stay in the same user namespace
as application process.

So we now result in a situation where we have to always create new pid
namespace to keep the third layer box as the init(pid=1) process for
application.

Change-Id: If83dd5bc10c292f43b9ad3e0fb59b31d222fccac
2022-07-04 11:20:17 +08:00
liujianqiang 23fd366502 feat: bump version to 1.3.2-1
update version.

Log:
Change-Id: I26eaabbda45ec2c580c67eb4858af932d95606ed
2022-06-24 16:57:42 +08:00
black-desk e8f1d2435e fix: fix code cause out_of_range exception
This reverts commit 6d6ce1ada7.

We need to configure $PATH to exec program. so we have to get this done
before call `util::Exec`

Change-Id: Ib171ac2cb4cdea9c0c1b47386eb2ff15f1efd120
2022-06-16 15:47:05 +08:00
black-desk 6d6ce1ada7 fix: remove code cause out_of_range exception
`p.env` might contain something like "AAA=", which cause kv.size=1,
  leading to `kv.at(1)` fail with `out_of_range` exception.

  As util::Exec use execvp which can handle environment variables, we
  don't need these lines of codes at all.

Change-Id: I03495a451d8c7530d5800a585abc606a7ab8ab3a
2022-06-16 09:21:13 +08:00
liujianqiang 4f23f491c4 feat: bump version to 1.3.0-1
update version.

Log:
Change-Id: Iedfb59fc69ad4803737f49ce471b90144f890747
2022-05-27 17:48:02 +08:00
black-desk f306b0d14c chore: typo
Add missing 'r'

Change-Id: Ife4000217d3562205f9ae44526e44ffcba3071c2
2022-05-24 11:52:48 +08:00
black-desk 40dc5b7fcf fix: message reader should parse remain content when meet a EOF
* When meet a EOF there can still be some contents in source, we
    should parse them.

Change-Id: Ib42a9823b73f4030bbbc8af709bd2a49273c299d
2022-05-23 14:08:20 +08:00
black-desk 08bcf05ed3 feat: exec new command in container
* message_reader.cpp for read/write from/to socket.
  * use signalfd + epoll to make ll-box work like a sane init

Change-Id: I392c9190462359c215b8efce6d551c57982b770c
2022-05-19 16:08:04 +08:00
black-desk 5d388432f7 fix: correct mount path for symbol link
* use realpath

  this commit fix two issues:

    * use of uninitalized buffer
    * readlink not work for relative symbol link

Change-Id: I1b3a9f2e43b303ebacd3c84b07c5245a1d993c3e
(cherry picked from commit 8ffef114624f56d9582f13f7eaf0e019e84238de)
2022-05-19 09:54:54 +08:00
liujianqiang 19d9c0e02d feat: bump version to 1.2.7-1
fix build issue.

Log:
Change-Id: I9ac558a2813a5b591e2648d6e3c86695704c2e19
2022-04-15 18:43:30 +08:00
black-desk 4ee8616114 fix: build issue
* Add nlohmann-json header file.
  * Remove nlohmann-json from debian/control.
  * Remove some unsupported arguments in debian/rules.

Change-Id: I60f6783c06a12ef754e056d859be5131af0d3b7d
2022-04-15 18:42:56 +08:00
liujianqiang 19830d2eaa feat: bump version to 1.2.6-1
1. adjust wait pid strategy.
2. print pidns in log.
3. configure uid/gid mapping after clone.
4. remove CLONE-FS flag when cloning NonePrivilegeProc.
5. wrong /dev/ptmx link.

Log:
Change-Id: Ic73eee817eb856baaa1d9ab9e4796ca6127b67ec
2022-03-22 13:43:48 +08:00
black-desk 12a6002703 fix: wrong /dev/ptmx link
* Swap from and to when making symlink
  * Add path to the rootfs of container as prefix

Change-Id: I9dcbd3952148a5b5994828b4da32853f6cb5b812
2022-03-22 09:43:26 +08:00
black-desk 22f6e94676 fix: remove CLONE_FS flag when cloning NonePrivilegeProc
* CLONE_FS cannot be use with CLONE_NEWUSER, which cause a EINVAL

  refer: man 2 clone
  > For security reasons, CLONE_NEWUSER cannot be specified in
  > conjunction with CLONE_FS.

Change-Id: I4b2463ad799d7c3c37d346824edca37918056cfb
2022-03-17 20:21:44 +08:00
black-desk f343b5159d refactor: configure uid/gid mapping after clone
* Move the uid(gid) mapping configure logic into cloned process
  * Void using of semaphore
  * Improve log of wait helper functions.

Change-Id: Ifb0ca77df62c07dc7513698be8895dfa52e1a443
2022-03-17 09:43:57 +08:00
black-desk b8822dc890 feat: print pidns in log
As we may create double nest pid namespace there might be two ll-box
  both think their pid=1. So when print log, we have to print the pid
  namespace them in as well as their pids.

Change-Id: Ie5716bd902f16c82fe315ed7faaabc50d0f48c7e
2022-03-17 09:43:57 +08:00
black-desk bf8c9ded08 fix: adjust wait pid strategy
- ll-box 1
    - ll-box 2
      - ll-box 3
        - app

  If app daemonlize itself, it will be adopted by the init process of
  its pid namespace. for now, this init process maybe ll-box 2 or ll-box
  3, so we have to wait -1 in ll-box 2 in case we do not create new pid
  namespace when creating ll-box 3 by clone.

Change-Id: I32548d5427a7598a806187259323653055e0603f
2022-03-15 16:35:18 +08:00
liujianqiang 63d1b59ed1 feat: bump version to 1.2.5-1
1. rename json fields.
2. close leaked fds.
3. remove forced CLONE_NEWPID flag for second clone.
4. add waitpid helper.
5. add support for dbus proxy.
6. remove unused code.

Log:
Change-Id: Ie23cb1f7d2db3355752bb6b7a5f3bb570531a1cf
2022-03-15 10:08:31 +08:00
black-desk d9ec9bbe91 fix: remove unused code
* Partly revert 4d40bce034

  Note: not sure why these unused codes make the third-level ll-box
        terminate, but the second-level ll-box donot exit.

Change-Id: I9ca5b72f1c8ed7ec0f25214a7972ca6f375806f7
2022-03-14 16:52:40 +08:00
black-desk 4d40bce034 feat: add support for dbus proxy
* Add support for dbus proxy

Change-Id: I1a20a042109394f549d9cb1e0b46b672009b335c
2022-03-14 13:09:05 +08:00
black-desk 54ca53e17c feat: add waitpid helper
* Add Wait helper function to wait child to exit and print it's
    exit status

Change-Id: I742c7ee29b9bdb48e404755e14a893f5bf48794c
2022-03-14 13:09:05 +08:00
black-desk 68c0aa9c9f fix: remove forced CLONE_NEWPID flag for second clone
this flag lead to a mismatch /proc mount between pidns

Change-Id: I4fa0ebd0c5e7ccfa28de265be226065c072e95d7
2022-03-11 16:05:46 +08:00
black-desk f9568f2aa0 fix: close leaked fds
* Close fds which be used to do mount

Change-Id: I4c2088a0eb136c10f575fde04ac61357fa3f3317
2022-03-10 11:17:57 +08:00
black-desk 3ec092e869 style: rename json fields
* add new marcos to handle json convert
  * container_root_path -> containerRootPath
  * lower_parent -> lowerParent

Change-Id: I18ea8ab7a6a84d374e3479096520f4774e391076
2022-03-09 16:09:16 +08:00
black-desk 5ba8cff2f6 feat: bump version to 1.2.4-1
1. void c_str() of destoryed string.

Log:
Change-Id: I8ab3b7818d910d41c1c51ab41a0ba04fb0242e7e
2022-03-08 17:23:53 +08:00
black-desk b8fcef5bc7 fix: void c_str() of destoryed string
* Add a debug message for container root
  * Void using c_str() of destoryed string rvalue

Change-Id: I9df1c7b13cc0a5b9b105b849227817367d822b9f
2022-03-08 17:11:48 +08:00
liujianqiang ead0494155 feat: bump version to 1.2.3-1
1. make fuse-overlayfs defalut.
2. fix update error info.
3. fix do mount by proc fd.

Log:
Change-Id: I6214741f0ef85ec9ad7fa600e764e582902a3af0
2022-03-08 13:30:01 +08:00