1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-26 12:29:07 +00:00

Compare commits

..

37 Commits

Author SHA1 Message Date
Travis Rowland
f374c49424 Merge pull request #373 from phusion/next
Update README.md regarding ignored env vars.
2017-03-20 21:00:45 -07:00
Travis Rowland
7e02e426e5 Update README.md regarding ignored env vars.
Closes #119
2017-03-20 20:59:39 -07:00
Travis Rowland
c375506f23 Merge pull request #370 from phusion/next
Updating README.md Fixes #228
2017-03-20 20:50:22 -07:00
Travis Rowland
5205fa04f7 Updating README.md Fixes #228 2017-03-20 20:48:24 -07:00
Travis Rowland
19170b8d38 Merge pull request #368 from kobotoolbox/armhf
`armhf` support.
2017-03-20 12:49:11 -07:00
Travis Rowland
8c842a35d7 Merge pull request #188 from endersonmaia/preserve-some-build-scripts
Preserve /build/{cleanup.sh,buildconfig} files.
2017-03-20 12:43:06 -07:00
Enderson Maia
e019d5fa11 Preserve /build/{cleanup.sh,buildconfig} files.
These files are useful for those who create Docker images based on this
baseimage, and need to make a final cleanup and/or use some
configurations that are inside buildconfig file.
2017-03-20 09:35:54 -03:00
Travis Rowland
75784205cf Merge branch 'pavlobaron-master' into next 2017-03-19 16:18:16 -07:00
Travis Rowland
d9e762730a cleaning up getter/setter for KILL_PROCESS_TIMEOUT/KILL_ALL_PROCESSES_TIMEOUT 2017-03-19 16:17:52 -07:00
Travis Rowland
7ec5a0a65f Merge branch 'master' of https://github.com/pavlobaron/baseimage-docker into pavlobaron-master 2017-03-19 16:15:04 -07:00
Travis Rowland
5cc60221e6 Document selection of syslog-ng over rsyslog
Fixes #114
2017-03-19 01:57:18 -07:00
Travis Rowland
15e27eefe6 Merge pull request #363 from lukecampbell/setuser
Cleanup and improves readability of setuser
2017-03-19 01:32:30 -07:00
Travis Rowland
1c6b9f11d1 Merge pull request #354 from wangyuehong/master
fix typos for README_ZH_cn_.md and README_ZH_tw_.md
2017-03-19 01:30:40 -07:00
Travis Rowland
e12eeb8083 Merge pull request #352 from jedie/patch-2
README: "RUN chmod +x /etc/my_init.d/logtime.sh"
2017-03-19 01:29:46 -07:00
Travis Rowland
d8a7ca7a4d Merge branch 'next' into patch-2 2017-03-19 01:29:24 -07:00
Travis Rowland
96a2d92978 Merge pull request #351 from jedie/patch-1
README: "RUN chmod +x /etc/service/memcached/run"
2017-03-19 01:26:04 -07:00
Travis Rowland
67a0c6d121 Merge branch 'next' into patch-1 2017-03-19 01:25:43 -07:00
Travis Rowland
1811cb7530 Merge pull request #348 from milinnovations/fix_cron_pam
Provided a fix for cron not working out of the box.
2017-03-19 01:20:24 -07:00
Travis Rowland
fdda2d42bf Merge pull request #339 from zhouhaibing089/logrotate-fix
override the logrotate.conf without `su root syslog` Fixes #338
2017-03-19 01:07:02 -07:00
Travis Rowland
4e5a7e91ce Merge pull request #336 from axilleas/fix-locales
Reconfigure locales and expose them in Dockerfile
2017-03-19 01:04:14 -07:00
Travis Rowland
e89e07acb5 Merge pull request #334 from nawork/master
Removing -f option of `docker tag`
2017-03-19 01:01:55 -07:00
Travis Rowland
116cf0e2dd Merge pull request #209 from pbecotte/master
Add instructions for enabling sshd on the fly without permanently enabli...
2017-03-19 00:26:28 -07:00
Travis Rowland
241c41e093 Merge pull request #203 from UnrealQuester/copy
Use COPY instead of ADD
2017-03-19 00:21:29 -07:00
Esmail Fadae
5a920d2291 No need to uninstall packages not available on armhf. 2017-03-06 14:52:15 +00:00
Esmail Fadae
bc06300b3e Use an armhf base image. 2017-03-06 14:51:22 +00:00
Luke Campbell
ffb22ecf60 Cleanup and improves readability of setuser 2017-02-24 12:03:53 -05:00
wangyuehong
7400c0b3b8 typo fix for README_ZH_cn_.md and README_ZH_tw_.md 2016-12-02 23:30:13 +09:00
Jens Diemer
4e80b8540a RUN chmod +x 2016-11-29 12:18:43 +01:00
Jens Diemer
9920d9d834 RUN chmod +x /etc/service/memcached/run is needed.
otherwise i get the error:
```
fatal: unable to start ./run: access denied
```
2016-11-29 12:05:34 +01:00
Matěj Týč
ac1211b0ed Provided a fix for cron not working out of the box. 2016-11-15 16:41:47 +01:00
Achilleas Pipinellis
bb3fef5377 Expose the locales in Dockerfile
While the locales are generated with locale-gen, this does not enforce
the en_US.UTF-8 locale inside the container.

See the following links for more information:

- https://github.com/docker/docker/issues/2424
- http://jaredmarkell.com/docker-and-locales/
2016-09-12 09:49:24 +02:00
zhouhaibing089
d3eceae5ef override the logrotate.conf without su root syslog 2016-09-12 10:49:28 +08:00
Andreas Elvers
ecdbe62eca Removing -f option of docker tag since this option is gone in docker 1.12.0. 2016-08-24 15:44:16 +02:00
Hongli Lai (Phusion)
24b8bcebc8 Fix 0.9.19 release date 2016-07-08 22:51:43 +02:00
pavlobaron
ea6b0ace79 configure process kill timeouts through environment with fallbacks 2016-01-22 09:49:48 +01:00
Alexander Buddenbrock
17eadef537 Use COPY instead of ADD
While COPY and ADD are essentially interchangeable here, it is still
considered good practice to use COPY whenever possible. From the docker
docks on best practices:

"Although ADD and COPY are functionally similar, generally speaking,
COPY is preferred. That’s because it’s more transparent than ADD.
[...] For other items (files, directories) that do not require ADD’s tar
auto-extraction capability, you should always use COPY."

Additionally, ADD commands were not cached prior to 0.7.3 (which was
released on 2013-01-02).
2015-12-14 21:34:23 +01:00
Paul Becotte
45c57234d7 Add instructions for enabling sshd on the fly without permanently enabling it in the dockerfile to the README 2015-04-02 11:36:39 -04:00
13 changed files with 152 additions and 53 deletions

View File

@@ -1,4 +1,4 @@
## 0.9.19 (release date: 2017-07-08)
## 0.9.19 (release date: 2016-07-08)
* Upgraded to Ubuntu 16.04. Thanks to Pierre Jacomet for submitting this patch.
* During shutdown, repeatedly tell Runit to shutdown services in order to workaround a potential race condition in Runit itself. Closes GH-315. Thanks to Chris Kite for submitting this patch.

View File

@@ -12,7 +12,7 @@ test:
env NAME=$(NAME) VERSION=$(VERSION) ./test/runner.sh
tag_latest:
docker tag -f $(NAME):$(VERSION) $(NAME):latest
docker tag $(NAME):$(VERSION) $(NAME):latest
release: test tag_latest
@if ! docker images $(NAME) | awk '{ print $$2 }' | grep -q -F $(VERSION); then echo "$(NAME) version $(VERSION) is not yet built. Please run 'make build'"; false; fi

View File

@@ -88,7 +88,7 @@ You can configure the stock `ubuntu` image yourself from your Dockerfile, so why
| Ubuntu 16.04 LTS | The base system. |
| A **correct** init process | _Main article: [Docker and the PID 1 zombie reaping problem](http://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/)._ <br><br>According to the Unix process model, [the init process](https://en.wikipedia.org/wiki/Init) -- PID 1 -- inherits all [orphaned child processes](https://en.wikipedia.org/wiki/Orphan_process) and must [reap them](https://en.wikipedia.org/wiki/Wait_(system_call)). Most Docker containers do not have an init process that does this correctly, and as a result their containers become filled with [zombie processes](https://en.wikipedia.org/wiki/Zombie_process) over time. <br><br>Furthermore, `docker stop` sends SIGTERM to the init process, which is then supposed to stop all services. Unfortunately most init systems don't do this correctly within Docker since they're built for hardware shutdowns instead. This causes processes to be hard killed with SIGKILL, which doesn't give them a chance to correctly deinitialize things. This can cause file corruption. <br><br>Baseimage-docker comes with an init process `/sbin/my_init` that performs both of these tasks correctly. |
| Fixes APT incompatibilities with Docker | See https://github.com/dotcloud/docker/issues/1024. |
| syslog-ng | A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed. <br><br>Only listens locally. All syslog messages are forwarded to "docker logs". |
| syslog-ng | A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed. <br><br>Only listens locally. All syslog messages are forwarded to "docker logs".<br><br>Why syslog-ng?<br>I've had bad experience with rsyslog. I regularly run into bugs with rsyslog, and once in a while it takes my log host down by entering a 100% CPU loop in which it can't do anything. Syslog-ng seems to be much more stable. |
| logrotate | Rotates and compresses logs on a regular basis. |
| SSH server | Allows you to easily login to your container to [inspect or administer](#login_ssh) things. <br><br>_SSH is **disabled by default** and is only one of the methods provided by baseimage-docker for this purpose. The other method is through [docker exec](#login_docker_exec). SSH is also provided as an alternative because `docker exec` comes with several caveats._<br><br>Password and challenge-response authentication are disabled by default. Only key authentication is allowed. |
| cron | The cron daemon must be running for cron jobs to work. |
@@ -169,7 +169,8 @@ In `memcached.sh` (make sure this file is chmod +x):
In `Dockerfile`:
RUN mkdir /etc/service/memcached
ADD memcached.sh /etc/service/memcached/run
COPY memcached.sh /etc/service/memcached/run
RUN chmod +x /etc/service/memcached/run
Note that the shell script must run the daemon **without letting it daemonize/fork it**. Usually, daemons provide a command line flag or a config file option for that.
@@ -183,9 +184,11 @@ The baseimage-docker init system, `/sbin/my_init`, runs the following scripts du
All scripts must exit correctly, e.g. with exit code 0. If any script exits with a non-zero exit code, the booting will fail.
**Important note:** If you are executing the container in interactive mode (i.e. when you run a container with `-it`), rather than daemon mode, you are sending stdout directly to the terminal (`-i` interactive `-t` terminal). If you are not calling `/sbin/my_init` in your run declaration, `/sbin/my_init` will not be executed, therefore your scripts will not be called during container startup.
The following example shows how you can add a startup script. This script simply logs the time of boot to the file /tmp/boottime.txt.
In `logtime.sh` (make sure this file is chmod +x):
In `logtime.sh`:
#!/bin/sh
date > /tmp/boottime.txt
@@ -193,7 +196,8 @@ In `logtime.sh` (make sure this file is chmod +x):
In `Dockerfile`:
RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh
COPY logtime.sh /etc/my_init.d/logtime.sh
RUN chmod +x /etc/my_init.d/logtime.sh
<a name="environment_variables"></a>
### Environment variables
@@ -203,6 +207,7 @@ If you use `/sbin/my_init` as the main container command, then any environment v
* Environment variables on Unix are inherited on a per-process basis. This means that it is generally not possible for a child process to change the environment variables of other processes.
* Because of the aforementioned point, there is no good central place for defining environment variables for all applications and services. Debian has the `/etc/environment` file but it only works in some situations.
* Some services change environment variables for child processes. Nginx is one such example: it removes all environment variables unless you explicitly instruct it to retain them through the `env` configuration option. If you host any applications on Nginx (e.g. using the [passenger-docker](https://github.com/phusion/passenger-docker) image, or using Phusion Passenger in your own image) then they will not see the environment variables that were originally passed by Docker.
* We ignore HOME, SHELL, USER and a bunch of other environment variables on purpose, because _not_ ignoring them will break multi-user containers. See https://github.com/phusion/baseimage-docker/pull/86 -- A workaround for setting the `HOME` environment variable looks like this: `RUN echo /root > /etc/container_environment/HOME`. See https://github.com/phusion/baseimage-docker/issues/119
`my_init` provides a solution for all these caveats.
@@ -407,6 +412,19 @@ Baseimage-docker disables the SSH server by default. Add the following to your D
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh
Alternatively, to enable sshd only for a single instance of your container, create a folder with a [startup script](#running_startup_scripts). The contents of that should be
### In myfolder/enable_ssh.sh (make sure this file is chmod +x):
#!/bin/sh
rm -f /etc/service/sshd/down
ssh-keygen -P "" -t dsa -f /etc/ssh/ssh_host_dsa_key
Then, you can start your container with
docker run -d -v `pwd`/myfolder:/etc/my_init.d my/dockerimage
This will initialize sshd on container boot. You can then access it with the insecure key as below, or using the methods to add a secure key. Further, you can publish the port to your machine with -p 22:2222 allowing you to ssh to localhost:2222 instead of looking up the ip address.
<a name="ssh_keys"></a>
#### About SSH keys
@@ -458,7 +476,7 @@ Instructions for logging in the container is the same as in section [Using the i
Edit your Dockerfile to install an SSH public key:
## Install an SSH of your choice.
ADD your_key.pub /tmp/your_key.pub
COPY your_key.pub /tmp/your_key.pub
RUN cat /tmp/your_key.pub >> /root/.ssh/authorized_keys && rm -f /tmp/your_key.pub
Then rebuild your image. Once you have that, start a container based on that image:

View File

@@ -142,7 +142,7 @@ Baseimage-docker *鼓励* 通过runit来运行多进程.
<a name="adding_additional_daemons"></a>
### 增加后台进程
你可以通过runit工具向你的镜像中添加后台进程(例如:你自己的某些应用).你需要编写一个运行你需要的后台进程的脚就可以了,runit工具会保证它的正常运行,如果进程死掉,runit也会重启它的.
你可以通过runit工具向你的镜像中添加后台进程(例如:你自己的某些应用).你需要编写一个运行你需要的后台进程的脚就可以了,runit工具会保证它的正常运行,如果进程死掉,runit也会重启它的.
脚本的名称必须是`run`,必须是可以运行的,它需要放到`/etc/service/<NAME>`.
@@ -155,7 +155,7 @@ Baseimage-docker *鼓励* 通过runit来运行多进程.
### 在Dockerfile中:
RUN mkdir /etc/service/memcached
ADD memcached.sh /etc/service/memcached/run
COPY memcached.sh /etc/service/memcached/run
注意脚本必须运行在后台的,**不能让他们进程进行daemonize/fork**.通常,后台进程会提供一个标志位或者配置文件.
@@ -177,7 +177,7 @@ baseimage-docker的初始化脚本 `/sbin/my_init`,在启动的时候进程运
### 在 Dockerfile中:
RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh
COPY logtime.sh /etc/my_init.d/logtime.sh
<a name="environment_variables"></a>
@@ -434,10 +434,10 @@ Baseimage-docker提供了一个灵活的方式运行只要一闪而过的命令,
* 不想使用`nsenter`,运行的进程和正在的进程会不一样.
* 不需要docker主机提供root权限.
* 运行你让用户登录到容器,而不需要登录到docker主机.然而,默认这是不启用的,因为baseimage-docker默认不是开放ssh服务的.
* 缺点
* 需要设置ssh key.然而,baseimage-docker会提供一中办法,会让key的生成会很容.阅读更多信息.
* 缺点
* 需要设置ssh key.然而,baseimage-docker会提供一中办法,会让key的生成会很容.阅读更多信息.
第一件事情,就是你需要确定你在容器中已经安装设置了ssh key. 默认,没有任何安装key的,所有你无法登录.为了方便的原因,我们提供了一个[已经生成的key](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key) [(PuTTY format)](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key.ppk),为了让你使用方便.然后,请注意这个key仅仅是为方便.他没有任何安全,因为它的key是在网络上提供的.**在生产环境,你必须使用你自己的key.**
第一件事情,就是你需要确定你在容器中已经安装设置了ssh key. 默认是不安装任何key的,所以任何人都无法登录.为了方便的原因,我们提供了一个[已经生成的key](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key) [(PuTTY format)](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key.ppk),为了让你使用方便.然后,请注意这个key仅仅是为方便.他没有任何安全,因为它的key是在网络上提供的.**在生产环境,你必须使用你自己的key.**
<a name="using_the_insecure_key_for_one_container_only"></a>
@@ -486,7 +486,7 @@ Baseimage-docker提供了一个灵活的方式运行只要一闪而过的命令,
编辑你的dockerfile,来安装ssh public key:
## 安装你自己的public key.
ADD your_key.pub /tmp/your_key.pub
COPY your_key.pub /tmp/your_key.pub
RUN cat /tmp/your_key.pub >> /root/.ssh/authorized_keys && rm -f /tmp/your_key.pub
重新创建你的镜像.一旦你创建成功,启动基于这个镜像的容器.

View File

@@ -143,7 +143,7 @@ The image is called `phusion/baseimage`, and is available on the Docker registry
<a name="adding_additional_daemons"></a>
### 增加後臺行程
你可以通過runit工具向你的鏡像中添加後臺行程(例如:你自己的某些應用).你需要編寫一個運行你需要的後臺行程的腳就可以了,runit工具會保證它的正常運行,如果行程死掉,runit也會重啓它的.
你可以通過runit工具向你的鏡像中添加後臺行程(例如:你自己的某些應用).你需要編寫一個運行你需要的後臺行程的腳就可以了,runit工具會保證它的正常運行,如果行程死掉,runit也會重啓它的.
腳本的名稱必須是`run`,必須是可以運行的,它需要放到`/etc/service/<NAME>`.
@@ -156,7 +156,7 @@ The image is called `phusion/baseimage`, and is available on the Docker registry
### 在Dockerfile中:
RUN mkdir /etc/service/memcached
ADD memcached.sh /etc/service/memcached/run
COPY memcached.sh /etc/service/memcached/run
注意腳本必須運行在後臺的,**不能讓他們行程進行daemonize/fork**.通常,後臺行程會提供一個標誌位或者配置文件.
@@ -178,7 +178,7 @@ baseimage-docker的初始化腳本 `/sbin/my_init`,在啓動的時候行程運
### 在 Dockerfile中:
RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh
COPY logtime.sh /etc/my_init.d/logtime.sh
<a name="environment_variables"></a>
@@ -435,10 +435,10 @@ Baseimage-docker提供了一個靈活的方式運行只要一閃而過的命令,
* 不想使用`nsenter`,運行的行程和正在的行程會不一樣.
* 不需要docker主機提供root權限.
* 運行你讓用戶登錄到容器,而不需要登錄到docker主機.然而,默認這是不啓用的,因爲baseimage-docker默認不是開放ssh服務的.
* 缺點
* 需要設置ssh key.然而,baseimage-docker會提供一中辦法,會讓key的生成會很容.閱讀更多信息.
* 缺點
* 需要設置ssh key.然而,baseimage-docker會提供一中辦法,會讓key的生成會很容.閱讀更多信息.
第一件事情,就是你需要確定你在容器中已經安裝設置了ssh key. 默認,沒有任何安裝key的,所有你無法登錄.爲了方便的原因,我們提供了一個[已經生成的key](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key) [(PuTTY format)](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key.ppk),爲了讓你使用方便.然後,請注意這個key僅僅是爲方便.他沒有任何安全,因爲它的key是在網絡上提供的.**在生產環境,你必須使用你自己的key.**
第一件事情,就是你需要確定你在容器中已經安裝設置了ssh key. 默認是不安裝任何key的,所以任何人都無法登錄.爲了方便的原因,我們提供了一個[已經生成的key](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key) [(PuTTY format)](https://github.com/phusion/baseimage-docker/blob/master/image/services/sshd/keys/insecure_key.ppk),爲了讓你使用方便.然後,請注意這個key僅僅是爲方便.他沒有任何安全,因爲它的key是在網絡上提供的.**在生產環境,你必須使用你自己的key.**
<a name="using_the_insecure_key_for_one_container_only"></a>
@@ -487,7 +487,7 @@ Baseimage-docker提供了一個靈活的方式運行只要一閃而過的命令,
編輯你的dockerfile,來安裝ssh public key:
## 安裝你自己的public key.
ADD your_key.pub /tmp/your_key.pub
COPY your_key.pub /tmp/your_key.pub
RUN cat /tmp/your_key.pub >> /root/.ssh/authorized_keys && rm -f /tmp/your_key.pub
重新創建你的鏡像.一旦你創建成功,啓動基於這個鏡像的容器.

View File

@@ -1,7 +1,7 @@
FROM ubuntu:16.04
FROM armhf/ubuntu
MAINTAINER Phusion <info@phusion.nl>
ADD . /bd_build
COPY . /bd_build
RUN /bd_build/prepare.sh && \
/bd_build/system_services.sh && \
@@ -9,4 +9,8 @@ RUN /bd_build/prepare.sh && \
/bd_build/fix_pam_bug.sh && \
/bd_build/cleanup.sh
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
CMD ["/sbin/my_init"]

View File

@@ -1,8 +1,8 @@
#!/usr/bin/python3 -u
import os, os.path, sys, stat, signal, errno, argparse, time, json, re
KILL_PROCESS_TIMEOUT = 5
KILL_ALL_PROCESSES_TIMEOUT = 5
KILL_PROCESS_TIMEOUT = os.environ.get('KILL_PROCESS_TIMEOUT', 5)
KILL_ALL_PROCESSES_TIMEOUT = os.environ.get('KILL_ALL_PROCESSES_TIMEOUT', 5)
LOG_LEVEL_ERROR = 1
LOG_LEVEL_WARN = 1
@@ -276,7 +276,7 @@ def main(args):
if not args.skip_startup_files:
run_startup_files()
runit_exited = False
exit_code = None

View File

@@ -1,26 +1,64 @@
#!/usr/bin/python3
import sys, os, pwd
'''
Copyright (c) 2013-2015 Phusion Holding B.V.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
'''
import sys
import os
import pwd
if len(sys.argv) < 3:
sys.stderr.write("Usage: /sbin/setuser USERNAME COMMAND [args..]\n")
sys.exit(1)
def abort(message):
sys.stderr.write("setuser: %s\n" % message)
sys.exit(1)
sys.stderr.write("setuser: %s\n" % message)
sys.exit(1)
def main():
'''
A simple alternative to sudo that executes a command as a user by setting
the user ID and user parameters to those described by the system and then
using execvp(3) to execute the command without the necessity of a TTY
'''
username = sys.argv[1]
try:
user = pwd.getpwnam(username)
except KeyError:
abort("user %s not found" % username)
os.initgroups(username, user.pw_gid)
os.setgid(user.pw_gid)
os.setuid(user.pw_uid)
os.environ['USER'] = username
os.environ['HOME'] = user.pw_dir
os.environ['UID'] = str(user.pw_uid)
try:
os.execvp(sys.argv[2], sys.argv[2:])
except OSError as e:
abort("cannot execute %s: %s" % (sys.argv[2], str(e)))
if __name__ == '__main__':
if len(sys.argv) < 3:
sys.stderr.write("Usage: /sbin/setuser USERNAME COMMAND [args..]\n")
sys.exit(1)
main()
username = sys.argv[1]
try:
user = pwd.getpwnam(username)
except KeyError:
abort("user %s not found" % username)
os.initgroups(username, user.pw_gid)
os.setgid(user.pw_gid)
os.setuid(user.pw_uid)
os.environ['USER'] = username
os.environ['HOME'] = user.pw_dir
os.environ['UID'] = str(user.pw_uid)
try:
os.execvp(sys.argv[2], sys.argv[2:])
except OSError as e:
abort("cannot execute %s: %s" % (sys.argv[2], str(e)))

View File

@@ -4,7 +4,7 @@ source /bd_build/buildconfig
set -x
apt-get clean
rm -rf /bd_build
ls -d -1 /bd_build/**/* | grep -v "cleanup.sh" | grep -v "buildconfig" | xargs rm -f
rm -rf /tmp/* /var/tmp/*
rm -rf /var/lib/apt/lists/*

View File

@@ -20,12 +20,12 @@ apt-get remove -y gdebi-core autoconf automake autopoint autotools-dev binutils
build-essential bzip2 cpp cpp-5 debhelper dh-autoreconf dh-strip-nondeterminism \
diffstat docbook-xml docbook-xsl dpkg-dev flex g++ g++-5 gcc gcc-5 gettext gettext-base \
groff-base intltool-debian libarchive-zip-perl libasan2 libasprintf0v5 libatomic1 \
libaudit-dev libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libcrack2 libcrack2-dev libcroco3 \
libaudit-dev libc-dev-bin libc6-dev libcc1-0 libcrack2 libcrack2-dev libcroco3 \
libdb-dev libdb5.3-dev libdpkg-perl libfile-stripnondeterminism-perl libfl-dev libgc1c2 \
libgcc-5-dev libgdbm3 libgomp1 libgpm2 libicu55 libisl15 libitm1 liblsan0 libmpc3 \
libmpfr4 libmpx0 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libperl5.22 \
libpipeline1 libquadmath0 libselinux1-dev libsepol1-dev libsigsegv2 libstdc++-5-dev \
libtimedate-perl libtool libtsan0 libubsan0 libunistring0 libxml2 libxml2-utils \
libgcc-5-dev libgdbm3 libgomp1 libgpm2 libicu55 libisl15 libmpc3 \
libmpfr4 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libperl5.22 \
libpipeline1 libselinux1-dev libsepol1-dev libsigsegv2 libstdc++-5-dev \
libtimedate-perl libtool libubsan0 libunistring0 libxml2 libxml2-utils \
libxslt1.1 linux-libc-dev m4 make man-db patch perl perl-modules-5.22 pkg-config \
po-debconf quilt sgml-base sgml-data w3m xml-core xsltproc xz-utils

View File

@@ -7,6 +7,8 @@ $minimal_apt_get_install cron
mkdir /etc/service/cron
chmod 600 /etc/crontab
cp /bd_build/services/cron/cron.runit /etc/service/cron/run
# Fix cron issues in 0.9.19, see also #345: https://github.com/phusion/baseimage-docker/issues/345
sed -i 's/^\s*session\s\+required\s\+pam_loginuid.so/# &/' /etc/pam.d/cron
## Remove useless cron entries.
# Checks for lost+found and scans for mtab.

View File

@@ -0,0 +1,36 @@
# see "man logrotate" for details
# rotate log files weekly
weekly
# use the syslog group by default, since this is the owning group
# of /var/log/syslog.
# su root syslog
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp, or btmp -- we'll rotate them here
/var/log/wtmp {
missingok
monthly
create 0664 root utmp
rotate 1
}
/var/log/btmp {
missingok
monthly
create 0660 root utmp
rotate 1
}
# system-specific logs may be configured here

View File

@@ -21,4 +21,5 @@ cp $SYSLOG_NG_BUILD_PATH/syslog-forwarder.runit /etc/service/syslog-forwarder/ru
## Install logrotate.
$minimal_apt_get_install logrotate
cp $SYSLOG_NG_BUILD_PATH/logrotate.conf /etc/logrotate.conf
cp $SYSLOG_NG_BUILD_PATH/logrotate_syslogng /etc/logrotate.d/syslog-ng