~ubuntu-branches/debian/jessie/systemd/jessie

« back to all changes in this revision

Viewing changes to src/nspawn.c

  • Committer: Package Import Robot
  • Author(s): Tollef Fog Heen, Tollef Fog Heen, Michael Biebl
  • Date: 2012-04-03 19:59:17 UTC
  • mfrom: (1.1.10) (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20120403195917-l532urrbg4pkreas
Tags: 44-1
[ Tollef Fog Heen ]
* New upstream version.
  - Backport 3492207: journal: PAGE_SIZE is not known on ppc and other
    archs
  - Backport 5a2a2a1: journal: react with immediate rotation to a couple
    of more errors
  - Backport 693ce21: util: never follow symlinks in rm_rf_children()
    Fixes CVE-2012-1174, closes: #664364
* Drop output message from init-functions hook, it's pointless.
* Only rmdir /lib/init/rw if it exists.
* Explicitly order debian-fixup before sysinit.target to prevent a
  possible race condition with the creation of sockets.  Thanks to
  Michael Biebl for debugging this.
* Always restart the initctl socket on upgrades, to mask sysvinit
  removing it.

[ Michael Biebl ]
* Remove workaround for non-interactive sessions from pam config again.
* Create compat /dev/initctl symlink in case we are upgrading from a system
  running a newer version of sysvinit (using /run/initctl) and sysvinit is
  replaced with systemd-sysv during the upgrade. Closes: #663219
* Install new man pages.
* Build-Depend on valac (>= 0.12) instead of valac-0.12. Closes: #663323

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <grp.h>
40
40
#include <linux/fs.h>
41
41
 
 
42
#include <systemd/sd-daemon.h>
 
43
 
42
44
#include "log.h"
43
45
#include "util.h"
44
46
#include "missing.h"
45
47
#include "cgroup-util.h"
46
 
#include "sd-daemon.h"
47
48
#include "strv.h"
48
49
#include "loopback-setup.h"
49
50
 
196
197
        }
197
198
 
198
199
        /* Fix the timezone, if possible */
199
 
        if (asprintf(&where, "%s/%s", dest, "/etc/localtime") >= 0) {
 
200
        if (asprintf(&where, "%s/etc/localtime", dest) >= 0) {
200
201
 
201
202
                if (mount("/etc/localtime", where, "bind", MS_BIND, NULL) >= 0)
202
203
                        mount("/etc/localtime", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
204
205
                free(where);
205
206
        }
206
207
 
 
208
        if (asprintf(&where, "%s/etc/timezone", dest) >= 0) {
 
209
 
 
210
                if (mount("/etc/timezone", where, "bind", MS_BIND, NULL) >= 0)
 
211
                        mount("/etc/timezone", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
 
212
 
 
213
                free(where);
 
214
        }
 
215
 
207
216
        return r;
208
217
}
209
218
 
361
370
 
362
371
        unsigned long l;
363
372
 
364
 
        for (l = 0; l <= MAX(63LU, (unsigned long) CAP_LAST_CAP); l++) {
 
373
        for (l = 0; l <= cap_last_cap(); l++) {
365
374
                unsigned i;
366
375
 
367
376
                for (i = 0; i < ELEMENTSOF(retain); i++)
372
381
                        continue;
373
382
 
374
383
                if (prctl(PR_CAPBSET_DROP, l) < 0) {
375
 
 
376
 
                        /* If this capability is not known, EINVAL
377
 
                         * will be returned, let's ignore this. */
378
 
                        if (errno == EINVAL)
379
 
                                break;
380
 
 
381
384
                        log_error("PR_CAPBSET_DROP failed: %m");
382
385
                        return -errno;
383
386
                }
400
403
        return r < 0 ? 0 : 1;
401
404
}
402
405
 
403
 
#define BUFFER_SIZE 1024
404
 
 
405
406
static int process_pty(int master, sigset_t *mask) {
406
407
 
407
 
        char in_buffer[BUFFER_SIZE], out_buffer[BUFFER_SIZE];
 
408
        char in_buffer[LINE_MAX], out_buffer[LINE_MAX];
408
409
        size_t in_buffer_full = 0, out_buffer_full = 0;
409
410
        struct epoll_event stdin_ev, stdout_ev, master_ev, signal_ev;
410
411
        bool stdin_readable = false, stdout_writable = false, master_readable = false, master_writable = false;
525
526
                       (master_readable && out_buffer_full <= 0) ||
526
527
                       (stdout_writable && out_buffer_full > 0)) {
527
528
 
528
 
                        if (stdin_readable && in_buffer_full < BUFFER_SIZE) {
 
529
                        if (stdin_readable && in_buffer_full < LINE_MAX) {
529
530
 
530
 
                                if ((k = read(STDIN_FILENO, in_buffer + in_buffer_full, BUFFER_SIZE - in_buffer_full)) < 0) {
 
531
                                if ((k = read(STDIN_FILENO, in_buffer + in_buffer_full, LINE_MAX - in_buffer_full)) < 0) {
531
532
 
532
533
                                        if (errno == EAGAIN || errno == EPIPE || errno == ECONNRESET || errno == EIO)
533
534
                                                stdin_readable = false;
559
560
                                }
560
561
                        }
561
562
 
562
 
                        if (master_readable && out_buffer_full < BUFFER_SIZE) {
 
563
                        if (master_readable && out_buffer_full < LINE_MAX) {
563
564
 
564
 
                                if ((k = read(master, out_buffer + out_buffer_full, BUFFER_SIZE - out_buffer_full)) < 0) {
 
565
                                if ((k = read(master, out_buffer + out_buffer_full, LINE_MAX - out_buffer_full)) < 0) {
565
566
 
566
567
                                        if (errno == EAGAIN || errno == EPIPE || errno == ECONNRESET || errno == EIO)
567
568
                                                master_readable = false;
713
714
        sigset_add_many(&mask, SIGCHLD, SIGWINCH, SIGTERM, SIGINT, -1);
714
715
        assert_se(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
715
716
 
716
 
        if ((pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWIPC|CLONE_NEWNS|CLONE_NEWPID|CLONE_NEWUTS|(arg_private_network ? CLONE_NEWNET : 0), NULL)) < 0) {
717
 
                log_error("clone() failed: %m");
 
717
        pid = syscall(__NR_clone, SIGCHLD|CLONE_NEWIPC|CLONE_NEWNS|CLONE_NEWPID|CLONE_NEWUTS|(arg_private_network ? CLONE_NEWNET : 0), NULL);
 
718
        if (pid < 0) {
 
719
                if (errno == EINVAL)
 
720
                        log_error("clone() failed, do you have namespace support enabled in your kernel? (You need UTS, IPC, PID and NET namespacing built in): %m");
 
721
                else
 
722
                        log_error("clone() failed: %m");
 
723
 
718
724
                goto finish;
719
725
        }
720
726