From 972dcfcdbfe75dcfeb777150c136576cf1a71e99 Mon Sep 17 00:00:00 2001 From: Tudor Florea Date: Fri, 9 Oct 2015 22:59:03 +0200 Subject: initial commit for Enea Linux 5.0 arm Signed-off-by: Tudor Florea --- .../0001-pseudo_has_unload-add-function.patch | 190 +++++++++++++++ meta/recipes-devtools/pseudo/files/fallback-group | 2 + meta/recipes-devtools/pseudo/files/fallback-passwd | 1 + .../pseudo-1.5.1-install-directory-mode.patch | 18 ++ .../pseudo/files/pseudo-fchmodat-permissions.patch | 264 +++++++++++++++++++++ .../pseudo/files/shutdownping.patch | 53 +++++ meta/recipes-devtools/pseudo/files/symver.patch | 26 ++ ...do_client.c-protect-pwd_lck-against-magic.patch | 55 +++++ ..._util-modify-interface-to-pseudo_etc_file.patch | 69 ++++++ ...nt.c-support-multiple-directories-in-PSEU.patch | 115 +++++++++ meta/recipes-devtools/pseudo/pseudo.inc | 133 +++++++++++ meta/recipes-devtools/pseudo/pseudo_1.5.1.bb | 20 ++ meta/recipes-devtools/pseudo/pseudo_1.6.2.bb | 22 ++ meta/recipes-devtools/pseudo/pseudo_git.bb | 11 + 14 files changed, 979 insertions(+) create mode 100644 meta/recipes-devtools/pseudo/files/0001-pseudo_has_unload-add-function.patch create mode 100644 meta/recipes-devtools/pseudo/files/fallback-group create mode 100644 meta/recipes-devtools/pseudo/files/fallback-passwd create mode 100644 meta/recipes-devtools/pseudo/files/pseudo-1.5.1-install-directory-mode.patch create mode 100644 meta/recipes-devtools/pseudo/files/pseudo-fchmodat-permissions.patch create mode 100644 meta/recipes-devtools/pseudo/files/shutdownping.patch create mode 100644 meta/recipes-devtools/pseudo/files/symver.patch create mode 100644 meta/recipes-devtools/pseudo/pseudo-1.6.2/0001-pseudo_client.c-protect-pwd_lck-against-magic.patch create mode 100644 meta/recipes-devtools/pseudo/pseudo-1.6.2/0002-pseudo_util-modify-interface-to-pseudo_etc_file.patch create mode 100644 meta/recipes-devtools/pseudo/pseudo-1.6.2/0003-pseudo_client.c-support-multiple-directories-in-PSEU.patch create mode 100644 meta/recipes-devtools/pseudo/pseudo.inc create mode 100644 meta/recipes-devtools/pseudo/pseudo_1.5.1.bb create mode 100644 meta/recipes-devtools/pseudo/pseudo_1.6.2.bb create mode 100644 meta/recipes-devtools/pseudo/pseudo_git.bb (limited to 'meta/recipes-devtools/pseudo') diff --git a/meta/recipes-devtools/pseudo/files/0001-pseudo_has_unload-add-function.patch b/meta/recipes-devtools/pseudo/files/0001-pseudo_has_unload-add-function.patch new file mode 100644 index 0000000000..b5c81c9d3e --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/0001-pseudo_has_unload-add-function.patch @@ -0,0 +1,190 @@ +From be97cb958f2934fa398fc8e344b25b84ebd4e90c Mon Sep 17 00:00:00 2001 +From: "Peter A. Bigot" +Date: Sun, 25 Aug 2013 19:22:09 -0500 +Subject: [PATCH] pseudo_has_unload: add function + +Various wrappers checked for a non-null pseudo_get_value("PSEUDO_UNLOAD") to +determine whether the environment should include the pseudo variables. None +of those checks freed the returned value when it was not null. The new +check function does. + +The new check function also sees whether PSEUDO_UNLOAD was defined in the +environment that should be used in the wrapped system call. This allows +pkg_postinst scripts to strip out the LD_PRELOAD setting, for example before +invoking qemu to execute commands in an environment that does not have +libpseudo.so. + +[YOCTO #4843] + +Upstream-Status: Pending +Signed-off-by: Peter A. Bigot +--- + ports/common/guts/execv.c | 2 +- + ports/common/guts/execve.c | 2 +- + ports/common/guts/execvp.c | 2 +- + ports/common/guts/fork.c | 2 +- + ports/linux/newclone/pseudo_wrappers.c | 2 +- + ports/linux/oldclone/pseudo_wrappers.c | 2 +- + ports/unix/guts/popen.c | 2 +- + ports/unix/guts/system.c | 2 +- + pseudo.h | 1 + + pseudo_util.c | 27 +++++++++++++++++++++++++++ + 10 files changed, 36 insertions(+), 8 deletions(-) + +diff --git a/ports/common/guts/execv.c b/ports/common/guts/execv.c +index 763e1f9..3e1f820 100644 +--- a/ports/common/guts/execv.c ++++ b/ports/common/guts/execv.c +@@ -19,7 +19,7 @@ + } + + pseudo_setupenv(); +- if (pseudo_get_value("PSEUDO_UNLOAD")) ++ if (pseudo_has_unload(NULL)) + pseudo_dropenv(); + + /* if exec() fails, we may end up taking signals unexpectedly... +diff --git a/ports/common/guts/execve.c b/ports/common/guts/execve.c +index a003657..ff6a44e 100644 +--- a/ports/common/guts/execve.c ++++ b/ports/common/guts/execve.c +@@ -20,7 +20,7 @@ + } + + new_environ = pseudo_setupenvp(envp); +- if (pseudo_get_value("PSEUDO_UNLOAD")) ++ if (pseudo_has_unload(new_environ)) + new_environ = pseudo_dropenvp(new_environ); + + /* if exec() fails, we may end up taking signals unexpectedly... +diff --git a/ports/common/guts/execvp.c b/ports/common/guts/execvp.c +index 5e75be7..04253c3 100644 +--- a/ports/common/guts/execvp.c ++++ b/ports/common/guts/execvp.c +@@ -20,7 +20,7 @@ + } + + pseudo_setupenv(); +- if (pseudo_get_value("PSEUDO_UNLOAD")) ++ if (pseudo_has_unload(NULL)) + pseudo_dropenv(); + + /* if exec() fails, we may end up taking signals unexpectedly... +diff --git a/ports/common/guts/fork.c b/ports/common/guts/fork.c +index df8abd7..bebe3b0 100644 +--- a/ports/common/guts/fork.c ++++ b/ports/common/guts/fork.c +@@ -12,7 +12,7 @@ + */ + if (rc == 0) { + pseudo_setupenv(); +- if (!pseudo_get_value("PSEUDO_UNLOAD")) { ++ if (!pseudo_has_unload(NULL)) { + pseudo_reinit_libpseudo(); + } else { + pseudo_dropenv(); +diff --git a/ports/linux/newclone/pseudo_wrappers.c b/ports/linux/newclone/pseudo_wrappers.c +index 9dbac42..257e8bb 100644 +--- a/ports/linux/newclone/pseudo_wrappers.c ++++ b/ports/linux/newclone/pseudo_wrappers.c +@@ -28,7 +28,7 @@ int wrap_clone_child(void *args) { + + if (!(flags & CLONE_VM)) { + pseudo_setupenv(); +- if (!pseudo_get_value("PSEUDO_UNLOAD")) { ++ if (!pseudo_has_unload(NULL)) { + pseudo_reinit_libpseudo(); + } else { + pseudo_dropenv(); +diff --git a/ports/linux/oldclone/pseudo_wrappers.c b/ports/linux/oldclone/pseudo_wrappers.c +index c0ce5dd..598d966 100644 +--- a/ports/linux/oldclone/pseudo_wrappers.c ++++ b/ports/linux/oldclone/pseudo_wrappers.c +@@ -22,7 +22,7 @@ int wrap_clone_child(void *args) { + + if (!(flags & CLONE_VM)) { + pseudo_setupenv(); +- if (!pseudo_get_value("PSEUDO_UNLOAD")) { ++ if (!pseudo_has_unload(NULL)) { + pseudo_reinit_libpseudo(); + } else { + pseudo_dropenv(); +diff --git a/ports/unix/guts/popen.c b/ports/unix/guts/popen.c +index 0ca16b0..5d44c0e 100644 +--- a/ports/unix/guts/popen.c ++++ b/ports/unix/guts/popen.c +@@ -9,7 +9,7 @@ + * in ways that avoid our usual enforcement of the environment. + */ + pseudo_setupenv(); +- if (pseudo_get_value("PSEUDO_UNLOAD")) ++ if (pseudo_has_unload(NULL)) + pseudo_dropenv(); + + rc = real_popen(command, mode); +diff --git a/ports/unix/guts/system.c b/ports/unix/guts/system.c +index 028b372..6351592 100644 +--- a/ports/unix/guts/system.c ++++ b/ports/unix/guts/system.c +@@ -9,7 +9,7 @@ + return 1; + + pseudo_setupenv(); +- if (pseudo_get_value("PSEUDO_UNLOAD")) ++ if (pseudo_has_unload(NULL)) + pseudo_dropenv(); + + rc = real_system(command); +diff --git a/pseudo.h b/pseudo.h +index 56760a4..f600793 100644 +--- a/pseudo.h ++++ b/pseudo.h +@@ -28,6 +28,7 @@ extern void pseudo_init_client(void); + void pseudo_dump_env(char **envp); + int pseudo_set_value(const char *key, const char *value); + char *pseudo_get_value(const char *key); ++int pseudo_has_unload(char * const *envp); + + #include "pseudo_tables.h" + +diff --git a/pseudo_util.c b/pseudo_util.c +index 8d0969e..16c70e0 100644 +--- a/pseudo_util.c ++++ b/pseudo_util.c +@@ -95,6 +95,33 @@ dump_env(char **envp) { + } + #endif + ++int ++pseudo_has_unload(char * const *envp) { ++ static const char unload[] = "PSEUDO_UNLOAD"; ++ static size_t unload_len = strlen(unload); ++ size_t i = 0; ++ ++ /* Is it in the caller environment? */ ++ if (NULL != getenv(unload)) ++ return 1; ++ ++ /* Is it in the environment cache? */ ++ if (pseudo_util_initted == -1) ++ pseudo_init_util(); ++ while (pseudo_env[i].key && strcmp(pseudo_env[i].key, unload)) ++ ++i; ++ if (pseudo_env[i].key && pseudo_env[i].value) ++ return 1; ++ ++ /* Is it in the operational environment? */ ++ while (envp && *envp) { ++ if ((!strncmp(*envp, unload, unload_len)) && ('=' == (*envp)[unload_len])) ++ return 1; ++ ++envp; ++ } ++ return 0; ++} ++ + /* Caller must free memory! */ + char * + pseudo_get_value(const char *key) { +-- +1.7.9.5 + diff --git a/meta/recipes-devtools/pseudo/files/fallback-group b/meta/recipes-devtools/pseudo/files/fallback-group new file mode 100644 index 0000000000..81bf732312 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/fallback-group @@ -0,0 +1,2 @@ +root:*:0: +mail:*:8: diff --git a/meta/recipes-devtools/pseudo/files/fallback-passwd b/meta/recipes-devtools/pseudo/files/fallback-passwd new file mode 100644 index 0000000000..c1458dc0f6 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/fallback-passwd @@ -0,0 +1 @@ +root::0:0:root:/home/root:/bin/sh diff --git a/meta/recipes-devtools/pseudo/files/pseudo-1.5.1-install-directory-mode.patch b/meta/recipes-devtools/pseudo/files/pseudo-1.5.1-install-directory-mode.patch new file mode 100644 index 0000000000..e8eaf13f74 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/pseudo-1.5.1-install-directory-mode.patch @@ -0,0 +1,18 @@ +Upstream-Status: Backport + +when install command sets the created directory mode, pseudo will change +the mode of the directory to 0700 incorrectly. + +Signed-off-by: yanjun.zhu +Signed-off-by: Kai Kang + +--- a/ports/unix/guts/mkdirat.c ++++ b/ports/unix/guts/mkdirat.c +@@ -25,6 +25,7 @@ + stat_rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW); + #endif + if (stat_rc != -1) { ++ buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode); + pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf); + } else { + pseudo_debug(1, "mkdir of %s succeeded, but stat failed: %s\n", diff --git a/meta/recipes-devtools/pseudo/files/pseudo-fchmodat-permissions.patch b/meta/recipes-devtools/pseudo/files/pseudo-fchmodat-permissions.patch new file mode 100644 index 0000000000..7b1f82d577 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/pseudo-fchmodat-permissions.patch @@ -0,0 +1,264 @@ +commit 7e67d082737b3df4788caf85fedd607b3acd9786 +Author: Peter Seebach +Date: Fri May 16 15:53:06 2014 -0500 + + permissions updates: improve fchmodat, mask out write bits + + Upstream-Status: Backport of several patches from 1.6 branch, + combined. + + Backport from pseudo 1.6 of improvements to fchmodat (handle + AT_SYMLINK_NOFOLLOW by rejecting it if the host system does, + to make GNU tar happier), also mask out write bits from filesystem + modes to avoid security problems. + + Also start tracking umask so we can use the right modes for + open, mkdir, and mknod. + + The 1.6 patches are: + + 87c53ea58befef48677846693aab445df1850e16 + 3c716e0bab4f0cfe4be84caa9ce5fd5e3f5e2a23 + c98e4f43b5d6499748a5057134408f4ba4854fb4 + 2f71a021b725c1aa415439209a89327f0b997d02 + 14925786b55202d8147b0af719038e8a23ef73c0 + +diff --git a/ChangeLog.txt b/ChangeLog.txt +index 113f675..cc966ce 100644 +--- a/ChangeLog.txt ++++ b/ChangeLog.txt +@@ -1,3 +1,18 @@ ++2014-05-27: ++ * (seebs) start noticing umask, mask it out from open or mkdir ++ calls rather than relying on underlying open/mkdir to do it. ++ ++2014-05-16: ++ * (seebs) fchmodat: don't drop flags, report failures, to improve ++ compatibility/consistency. Cache the knowledge that ++ AT_SYMLINK_NOFOLLOW gets ENOTSUP. ++ * (seebs) mask out group/other write bits in real filesystem to ++ reduce risks when assembling a rootfs including world-writeable ++ directories. ++ ++2014-05-15: ++ * (seebs) drop flags when calling fchmodat() to appease GNU tar. ++ + 2013-02-27: + * (seebs) Oh, hey, what if I took out my debug messages? + * (seebs) update docs a bit to reduce bitrot +diff --git a/makewrappers b/makewrappers +index e87cc56..0127766 100755 +--- a/makewrappers ++++ b/makewrappers +@@ -204,6 +204,7 @@ class Function: + 'uid_t': '0', + 'int': '-1', + 'long': '-1', ++ 'mode_t': '0', + 'ssize_t': '-1' + } + +diff --git a/ports/darwin/guts/open.c b/ports/darwin/guts/open.c +index c66cc15..520bb70 100644 +--- a/ports/darwin/guts/open.c ++++ b/ports/darwin/guts/open.c +@@ -9,6 +9,9 @@ + struct stat buf = { }; + int existed = 1; + int save_errno; ++ ++ /* mask out mode bits appropriately */ ++ mode = mode & ~pseudo_umask; + #ifdef PSEUDO_FORCE_ASYNCH + flags &= ~O_SYNC; + #endif +diff --git a/ports/linux/guts/__xmknodat.c b/ports/linux/guts/__xmknodat.c +index 59b4f2f..0888b8a 100644 +--- a/ports/linux/guts/__xmknodat.c ++++ b/ports/linux/guts/__xmknodat.c +@@ -9,6 +9,9 @@ + pseudo_msg_t *msg; + struct stat64 buf; + ++ /* mask out mode bits appropriately */ ++ mode = mode & ~pseudo_umask; ++ + /* we don't use underlying call, so _ver is irrelevant to us */ + (void) ver; + +diff --git a/ports/linux/guts/openat.c b/ports/linux/guts/openat.c +index 8460073..4053549 100644 +--- a/ports/linux/guts/openat.c ++++ b/ports/linux/guts/openat.c +@@ -10,6 +10,9 @@ + int existed = 1; + int save_errno; + ++ /* mask out mode bits appropriately */ ++ mode = mode & ~pseudo_umask; ++ + #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS + if (dirfd != AT_FDCWD) { + errno = ENOSYS; +diff --git a/ports/unix/guts/fchmodat.c b/ports/unix/guts/fchmodat.c +index 59a92ce..69a953c 100644 +--- a/ports/unix/guts/fchmodat.c ++++ b/ports/unix/guts/fchmodat.c +@@ -8,6 +8,7 @@ + */ + PSEUDO_STATBUF buf; + int save_errno = errno; ++ static int picky_fchmodat = 0; + + #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS + if (dirfd != AT_FDCWD) { +@@ -15,6 +16,16 @@ + return -1; + } + if (flags & AT_SYMLINK_NOFOLLOW) { ++ /* Linux, as of this writing, will always reject this. ++ * GNU tar relies on getting the rejection. To cut down ++ * on traffic, we check for the failure, and if we saw ++ * a failure previously, we reject it right away and tell ++ * the caller to retry. ++ */ ++ if (picky_fchmodat) { ++ errno = ENOTSUP; ++ return -1; ++ } + rc = base_lstat(path, &buf); + } else { + rc = base_stat(path, &buf); +@@ -50,13 +61,22 @@ + + /* user bits added so "root" can always access files. */ + #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS +- /* note: if path was a symlink, and AT_NOFOLLOW_SYMLINKS was ++ /* note: if path was a symlink, and AT_SYMLINK_NOFOLLOW was + * specified, we already bailed previously. */ + real_chmod(path, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode))); + #else +- real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode)), flags); ++ rc = real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, S_ISDIR(buf.st_mode)), flags); ++ /* AT_SYMLINK_NOFOLLOW isn't supported by fchmodat. GNU tar ++ * tries to use it anyway, figuring it can just retry if that ++ * fails. So we want to report that *particular* failure instead ++ * of doing the fallback. ++ */ ++ if (rc == -1 && errno == ENOTSUP && (flags & AT_SYMLINK_NOFOLLOW)) { ++ picky_fchmodat = 1; ++ return -1; ++ } + #endif +- /* we ignore a failure from underlying fchmod, because pseudo ++ /* we otherwise ignore failures from underlying fchmod, because pseudo + * may believe you are permitted to change modes that the filesystem + * doesn't. Note that we also don't need to know whether the + * file might be a (pseudo) block device or some such; pseudo +diff --git a/ports/unix/guts/mkdirat.c b/ports/unix/guts/mkdirat.c +index e846b70..e0b6af9 100644 +--- a/ports/unix/guts/mkdirat.c ++++ b/ports/unix/guts/mkdirat.c +@@ -6,11 +6,14 @@ + * wrap_mkdirat(int dirfd, const char *path, mode_t mode) { + * int rc = -1; + */ ++ /* mask out mode bits appropriately */ ++ mode = mode & ~pseudo_umask; + #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS + if (dirfd != AT_FDCWD) { + errno = ENOSYS; + return -1; + } ++ + rc = real_mkdir(path, PSEUDO_FS_MODE(mode, 1)); + #else + rc = real_mkdirat(dirfd, path, PSEUDO_FS_MODE(mode, 1)); +diff --git a/ports/unix/guts/mknodat.c b/ports/unix/guts/mknodat.c +index 6fd5b42..5d8d47c 100644 +--- a/ports/unix/guts/mknodat.c ++++ b/ports/unix/guts/mknodat.c +@@ -10,6 +10,9 @@ + PSEUDO_STATBUF buf; + int save_errno = errno; + ++ /* mask out mode bits appropriately */ ++ mode = mode & ~pseudo_umask; ++ + #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS + if (dirfd != AT_FDCWD) { + errno = ENOSYS; +diff --git a/ports/unix/guts/umask.c b/ports/unix/guts/umask.c +new file mode 100644 +index 0000000..6b060d3 +--- /dev/null ++++ b/ports/unix/guts/umask.c +@@ -0,0 +1,14 @@ ++/* ++ * Copyright (c) 2014 Wind River Systems; see ++ * guts/COPYRIGHT for information. ++ * ++ * mode_t umask(mode_t mask) ++ * mode_t rc = 0; ++ */ ++ ++ pseudo_umask = mask; ++ rc = real_umask(mask); ++ ++/* return rc; ++ * } ++ */ +diff --git a/ports/unix/wrapfuncs.in b/ports/unix/wrapfuncs.in +index 8460a65..e0e9739 100644 +--- a/ports/unix/wrapfuncs.in ++++ b/ports/unix/wrapfuncs.in +@@ -67,3 +67,4 @@ void sync(void); /* async_skip= */ + int syncfs(int fd); /* async_skip=0 */ + int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags); /* async_skip=0 */ + int msync(void *addr, size_t length, int flags); /* async_skip=0 */ ++mode_t umask(mode_t mask); +diff --git a/pseudo_client.c b/pseudo_client.c +index b6d11a6..535c810 100644 +--- a/pseudo_client.c ++++ b/pseudo_client.c +@@ -71,6 +71,8 @@ int pseudo_disabled = 0; + int pseudo_allow_fsync = 0; + static int pseudo_local_only = 0; + ++int pseudo_umask = 022; ++ + static char **fd_paths = NULL; + static int nfds = 0; + static int messages = 0; +@@ -219,6 +221,9 @@ pseudo_init_client(void) { + if (!pseudo_disabled && !pseudo_inited) { + char *pseudo_path = 0; + ++ pseudo_umask = umask(022); ++ umask(pseudo_umask); ++ + pseudo_path = pseudo_prefix_path(NULL); + if (pseudo_prefix_dir_fd == -1) { + if (pseudo_path) { +diff --git a/pseudo_client.h b/pseudo_client.h +index f36a772..5bf820e 100644 +--- a/pseudo_client.h ++++ b/pseudo_client.h +@@ -72,6 +72,8 @@ extern char *pseudo_passwd; + extern size_t pseudo_chroot_len; + extern int pseudo_nosymlinkexp; + ++extern int pseudo_umask; ++ + /* Root can read and write files, and enter directories which have no + * read, write, or execute permissions. (But can't execute files without + * execute permissions!) +@@ -85,6 +87,6 @@ extern int pseudo_nosymlinkexp; + * None of this will behave very sensibly if umask has 0700 bits in it; + * this is a known limitation. + */ +-#define PSEUDO_FS_MODE(mode, isdir) ((mode) | S_IRUSR | S_IWUSR | ((isdir) ? S_IXUSR : 0)) +-#define PSEUDO_DB_MODE(fs_mode, user_mode) (((fs_mode) & ~0700) | ((user_mode & 0700))) ++#define PSEUDO_FS_MODE(mode, isdir) (((mode) | S_IRUSR | S_IWUSR | ((isdir) ? S_IXUSR : 0)) & ~(S_IWGRP | S_IWOTH)) ++#define PSEUDO_DB_MODE(fs_mode, user_mode) (((fs_mode) & ~0722) | ((user_mode & 0722))) + diff --git a/meta/recipes-devtools/pseudo/files/shutdownping.patch b/meta/recipes-devtools/pseudo/files/shutdownping.patch new file mode 100644 index 0000000000..8af8e0b594 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/shutdownping.patch @@ -0,0 +1,53 @@ +There is a potential issue with the fastop code in pseudo since a process may +exit and allow some other function to run before the server has processed +the commands run by the process. Issues have been see with unpredictable +file permissions. + +To avoid this, we ping the server before exitting which guarantees it has +processed the current command queue. + +Debugged-by: RP +Fix written by peter.seebach@windriver.com + +Upstream-Status: Submitted + +[YOCTO #5132] + +diff --git a/pseudo_client.c b/pseudo_client.c +index f58ce4c..20943b6 100644 +--- a/pseudo_client.c ++++ b/pseudo_client.c +@@ -75,6 +75,9 @@ static int nfds = 0; + static int messages = 0; + static struct timeval message_time = { .tv_sec = 0 }; + static int pseudo_inited = 0; ++ ++static int sent_messages = 0; ++ + int pseudo_nosymlinkexp = 0; + + /* note: these are int, not uid_t/gid_t, so I can use 'em with scanf */ +@@ -711,6 +714,11 @@ client_ping(void) { + return 0; + } + ++static void ++void_client_ping(void) { ++ client_ping(); ++} ++ + int + pseudo_fd(int fd, int how) { + int newfd; +@@ -1043,6 +1051,11 @@ pseudo_client_op(pseudo_op_t op, int access, int fd, int dirfd, const char *path + /* disable wrappers */ + pseudo_antimagic(); + ++ if (!sent_messages) { ++ sent_messages = 1; ++ atexit(void_client_ping); ++ } ++ + if (op == OP_RENAME) { + va_list ap; + va_start(ap, buf); diff --git a/meta/recipes-devtools/pseudo/files/symver.patch b/meta/recipes-devtools/pseudo/files/symver.patch new file mode 100644 index 0000000000..8d1b377ec0 --- /dev/null +++ b/meta/recipes-devtools/pseudo/files/symver.patch @@ -0,0 +1,26 @@ +When running as pseudo-nativesdk, we might need to run host binaries +linked against the host libc. Having a 2.14 libc dependency from memcpy is +problematic so instruct the linker to use older symbols. + +Upstream-Status: Pending + +RP 2012/4/22 + +Index: pseudo-1.3/pseudo.h +=================================================================== +--- pseudo-1.3.orig/pseudo.h 2012-04-22 12:17:59.078909060 +0000 ++++ pseudo-1.3/pseudo.h 2012-04-22 12:32:42.954888587 +0000 +@@ -29,6 +29,13 @@ + int pseudo_set_value(const char *key, const char *value); + char *pseudo_get_value(const char *key); + ++#ifdef __amd64__ ++#define GLIBC_COMPAT_SYMBOL(SYM) __asm__(".symver " #SYM "," #SYM "@GLIBC_2.2.5") ++#else ++#define GLIBC_COMPAT_SYMBOL(SYM) __asm__(".symver " #SYM "," #SYM "@GLIBC_2.0") ++#endif ++GLIBC_COMPAT_SYMBOL(memcpy); ++ + #include "pseudo_tables.h" + + extern void pseudo_debug_verbose(void); diff --git a/meta/recipes-devtools/pseudo/pseudo-1.6.2/0001-pseudo_client.c-protect-pwd_lck-against-magic.patch b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0001-pseudo_client.c-protect-pwd_lck-against-magic.patch new file mode 100644 index 0000000000..b1bb9fb59c --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0001-pseudo_client.c-protect-pwd_lck-against-magic.patch @@ -0,0 +1,55 @@ +From e11468a47369596f57c5e99bd0a3dd58b2c6d5e0 Mon Sep 17 00:00:00 2001 +From: "Peter A. Bigot" +Date: Sun, 12 Oct 2014 08:27:14 -0500 +Subject: [PATCH 1/3] pseudo_client.c: protect pwd_lck against magic + +While attempting to diagnose unexpected uid/gid assignment I added +--without-passwd-fallback to the pseudo build. This caused build +failures due to inability to lock /etc/passwd. + +Instrumentation revealed that attempts to create the lock file ended up +with pseudo_etc_file() creating the correct lock name, but the +subsequent open had an extra PSEUDO_PASSWD directory prefix causing +it to fail. + +Inspection of pseudo_client shows the only other use of PSEUDO_ETC_FILE +to be protected against magic. Applying the same shield to the +unprotected calls in pseudo_pwd_lck_{open,close} fixes the issue. + +Upstream-Status: Pending +Signed-off-by: Peter A. Bigot +--- + pseudo_client.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/pseudo_client.c b/pseudo_client.c +index 8deaa1b..442dd19 100644 +--- a/pseudo_client.c ++++ b/pseudo_client.c +@@ -416,20 +416,24 @@ pseudo_pwd_lck_open(void) { + } + } + pseudo_pwd_lck_close(); ++ pseudo_antimagic(); + pseudo_pwd_lck_fd = PSEUDO_ETC_FILE(".pwd.lock", + pseudo_pwd_lck_name, O_RDWR | O_CREAT); ++ pseudo_magic(); + return pseudo_pwd_lck_fd; + } + + int + pseudo_pwd_lck_close(void) { + if (pseudo_pwd_lck_fd != -1) { ++ pseudo_antimagic(); + close(pseudo_pwd_lck_fd); + if (pseudo_pwd_lck_name) { + unlink(pseudo_pwd_lck_name); + free(pseudo_pwd_lck_name); + pseudo_pwd_lck_name = 0; + } ++ pseudo_magic(); + pseudo_pwd_lck_fd = -1; + return 0; + } else { +-- +1.8.5.5 diff --git a/meta/recipes-devtools/pseudo/pseudo-1.6.2/0002-pseudo_util-modify-interface-to-pseudo_etc_file.patch b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0002-pseudo_util-modify-interface-to-pseudo_etc_file.patch new file mode 100644 index 0000000000..f3fef26d48 --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0002-pseudo_util-modify-interface-to-pseudo_etc_file.patch @@ -0,0 +1,69 @@ +From f05def2bbd5507084672bc9072ffe0e5101e9b47 Mon Sep 17 00:00:00 2001 +From: "Peter A. Bigot" +Date: Sun, 12 Oct 2014 11:35:57 -0500 +Subject: [PATCH 2/3] pseudo_util: modify interface to pseudo_etc_file + +* Make the search directory pointers const: there is no reason why this + function should be allowed to mutate the directories. + +* Change the search directory argument from an array of pointers to a + pointer-to-pointers to prepare for an upcoming enhancement. + +Upstream-Status: Pending +Signed-off-by: Peter A. Bigot +--- + pseudo.h | 2 +- + pseudo_client.c | 2 +- + pseudo_util.c | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/pseudo.h b/pseudo.h +index 92020e4..05813c1 100644 +--- a/pseudo.h ++++ b/pseudo.h +@@ -86,7 +86,7 @@ extern int pseudo_logfile(char *defname); + extern ssize_t pseudo_sys_path_max(void); + extern ssize_t pseudo_path_max(void); + #define PSEUDO_PWD_MAX 4096 +-extern int pseudo_etc_file(const char *filename, char *realname, int flags, char *path[], int dircount); ++extern int pseudo_etc_file(const char *filename, char *realname, int flags, const char **search_dirs, int dircount); + extern void pseudo_stat32_from64(struct stat *, const struct stat64 *); + extern void pseudo_stat64_from32(struct stat64 *, const struct stat *); + +diff --git a/pseudo_client.c b/pseudo_client.c +index 442dd19..7a4d7fa 100644 +--- a/pseudo_client.c ++++ b/pseudo_client.c +@@ -93,7 +93,7 @@ gid_t pseudo_egid; + gid_t pseudo_sgid; + gid_t pseudo_fgid; + +-#define PSEUDO_ETC_FILE(filename, realname, flags) pseudo_etc_file(filename, realname, flags, (char *[]) { pseudo_chroot, pseudo_passwd, PSEUDO_PASSWD_FALLBACK }, PSEUDO_PASSWD_FALLBACK ? 3 : 2) ++#define PSEUDO_ETC_FILE(filename, realname, flags) pseudo_etc_file(filename, realname, flags, (const char *[]) { pseudo_chroot, pseudo_passwd, PSEUDO_PASSWD_FALLBACK }, PSEUDO_PASSWD_FALLBACK ? 3 : 2) + + /* helper function to make a directory, just like mkdir -p. + * Can't use system() because the child shell would end up trying +diff --git a/pseudo_util.c b/pseudo_util.c +index e4e1fc8..647d3ad 100644 +--- a/pseudo_util.c ++++ b/pseudo_util.c +@@ -1264,7 +1264,7 @@ FILE *pseudo_host_etc_group_file = &pseudo_fake_group_file; + #endif + + int +-pseudo_etc_file(const char *file, char *realname, int flags, char *search_dirs[], int dircount) { ++pseudo_etc_file(const char *file, char *realname, int flags, const char **search_dirs, int dircount) { + char filename[pseudo_path_max()]; + int rc = -1; + +@@ -1280,7 +1280,7 @@ pseudo_etc_file(const char *file, char *realname, int flags, char *search_dirs[] + return -1; + } + for (i = 0; i < dircount; ++i) { +- char *s = search_dirs[i]; ++ const char *s = search_dirs[i]; + if (!s) + continue; + #if PSEUDO_PORT_DARWIN +-- +1.8.5.5 diff --git a/meta/recipes-devtools/pseudo/pseudo-1.6.2/0003-pseudo_client.c-support-multiple-directories-in-PSEU.patch b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0003-pseudo_client.c-support-multiple-directories-in-PSEU.patch new file mode 100644 index 0000000000..8303b5ce5f --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo-1.6.2/0003-pseudo_client.c-support-multiple-directories-in-PSEU.patch @@ -0,0 +1,115 @@ +From 09f04dc36f21c179235109b3dcddce9dda9a8ba8 Mon Sep 17 00:00:00 2001 +From: "Peter A. Bigot" +Date: Sun, 12 Oct 2014 12:17:48 -0500 +Subject: [PATCH 3/3] pseudo_client.c: support multiple directories in + PSEUDO_PASSWD + +For OpenEmbedded it is highly unlikely that using the build host passwd +file is the right approach. Most packages can be built with a pseudo +that was configured --without-passwd-fallback, since +PSEUDO_PASSWD=${STAGING_DIR_TARGET} suffices. + +This fails when building images, because image.bbclass (correctly) +overrides to PSEUDO_PASSWD=${IMAGE_ROOTFS}. However, the rootfs +/etc/passwd is not created until the post-install phase of base-passwd, +which is long after a passwd file is required. For example, the smart +RPM interface wants to look up uid 0 right away. The right solution +here is to look first in ${IMAGE_ROOTFS}, then fallback to +a location holding immutable files with the minimum user/group settings +necessary to successfully get base-passwd onto the target. + +Rather than rework pseudo to change PSEUDO_PASSWD_FALLBACK to be a +run-time rather than compile-time specification, rework the handling of +PSEUDO_PASSWD so that it is a colon-separated list of directories that +are processed in order. + +Upstream-Status: Pending +Signed-off-by: Peter A. Bigot +--- + pseudo_client.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 49 insertions(+), 1 deletion(-) + +diff --git a/pseudo_client.c b/pseudo_client.c +index 7a4d7fa..b52b86a 100644 +--- a/pseudo_client.c ++++ b/pseudo_client.c +@@ -75,6 +75,8 @@ int pseudo_umask = 022; + + static char **fd_paths = NULL; + static int nfds = 0; ++static const char **passwd_paths = NULL; ++static int npasswd_paths = 0; + static int messages = 0; + static struct timeval message_time = { .tv_sec = 0 }; + static int pseudo_inited = 0; +@@ -93,7 +95,7 @@ gid_t pseudo_egid; + gid_t pseudo_sgid; + gid_t pseudo_fgid; + +-#define PSEUDO_ETC_FILE(filename, realname, flags) pseudo_etc_file(filename, realname, flags, (const char *[]) { pseudo_chroot, pseudo_passwd, PSEUDO_PASSWD_FALLBACK }, PSEUDO_PASSWD_FALLBACK ? 3 : 2) ++#define PSEUDO_ETC_FILE(filename, realname, flags) pseudo_etc_file(filename, realname, flags, passwd_paths, npasswd_paths) + + /* helper function to make a directory, just like mkdir -p. + * Can't use system() because the child shell would end up trying +@@ -117,6 +119,42 @@ mkdir_p(char *path) { + (void) mkdir(path, 0755); + } + ++static int ++build_passwd_paths(const char **paths) ++{ ++ int np = 0; ++ ++ if (pseudo_chroot) { ++ if (paths) { ++ paths[np] = pseudo_chroot; ++ } ++ ++np; ++ } ++ if (pseudo_passwd) { ++ const char *cp = pseudo_passwd; ++ const char *next = strchr(cp, ':'); ++ while (next) { ++ if (paths) { ++ paths[np] = strndup(cp, next-cp); ++ } ++ ++np; ++ cp = next+1; ++ next = strchr(cp, ':'); ++ } ++ if (paths) { ++ paths[np] = strdup(cp); ++ } ++ ++np; ++ } ++ if (PSEUDO_PASSWD_FALLBACK) { ++ if (paths) { ++ paths[np] = PSEUDO_PASSWD_FALLBACK; ++ } ++ ++np; ++ } ++ return np; ++} ++ + void + pseudo_init_client(void) { + char *env; +@@ -329,6 +367,16 @@ pseudo_init_client(void) { + } + free(env); + ++ npasswd_paths = build_passwd_paths(NULL); ++ if (npasswd_paths) { ++ passwd_paths = malloc(npasswd_paths * sizeof(*passwd_paths)); ++ if (!passwd_paths) { ++ pseudo_diag("couldn't allocate space for passwd paths.\n"); ++ exit(1); ++ } ++ build_passwd_paths(passwd_paths); ++ } ++ + pseudo_inited = 1; + } + if (!pseudo_disabled) +-- +1.8.5.5 diff --git a/meta/recipes-devtools/pseudo/pseudo.inc b/meta/recipes-devtools/pseudo/pseudo.inc new file mode 100644 index 0000000000..11a8514675 --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo.inc @@ -0,0 +1,133 @@ +# Note: Due to the bitbake wrapper script, making changes to pseudo can be +# difficult. To work around the current version of the wrapper use: +# BBFETCH2=True PSEUDO_BUILD=1 ../bitbake/bin/bitbake pseudo-native [-c CMD] + +SUMMARY = "Pseudo gives fake root capabilities to a normal user" +HOMEPAGE = "http://git.yoctoproject.org/cgit/cgit.cgi/pseudo" +LIC_FILES_CHKSUM = "file://COPYING;md5=243b725d71bb5df4a1e5920b344b86ad" +SECTION = "base" +LICENSE = "LGPL2.1" +DEPENDS = "sqlite3 attr" + +FILES_${PN} = "${prefix}/lib/pseudo/lib*/libpseudo.so ${bindir}/* ${localstatedir}/pseudo ${prefix}/var/pseudo" +FILES_${PN}-dbg += "${prefix}/lib/pseudo/lib*/.debug" +INSANE_SKIP_${PN} += "libdir" +INSANE_SKIP_${PN}-dbg += "libdir" + +PROVIDES += "virtual/fakeroot" + +MAKEOPTS = "" + +inherit siteinfo + +do_configure () { + : +} + +NO32LIBS ??= "1" +NO32LIBS_class-nativesdk = "1" + +# Compile for the local machine arch... +do_compile () { + if [ "${SITEINFO_BITS}" = "64" ]; then + ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib${SITEINFO_BITS} --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --enable-static-sqlite --without-rpath + else + ${S}/configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --cflags="${CFLAGS}" --bits=${SITEINFO_BITS} --enable-static-sqlite --without-rpath + fi + oe_runmake ${MAKEOPTS} +} + +maybe_make32() { + # We probably don't need to build 32-bit binaries. + make32=false + if [ "${SITEINFO_BITS}" = "64" ]; then + case "${NO32LIBS}" in + 0) make32=true + ;; + 1) make32=false + ;; + *) # If unset, build 32-bit if we think we can. + if [ -e "/usr/include/gnu/stubs-32.h" ]; then + make32=true + fi + ;; + esac + fi + if $make32; then + if ! [ -e "/usr/include/gnu/stubs-32.h" ]; then + warn_32bit_missing + else + bbnote "Attempting to build 32-bit libpseudo.so for ${PN}." + fi + else + bbnote "Building/installing only 64-bit libpseudo.so for ${PN}." + bbnote "If you need to run 32-bit executables, ensure that NO32LIBS is set to 0." + fi +} + +warn_32bit_missing() { + bbwarn "Can't find stubs-32.h, but usually need it to build 32-bit libpseudo." + bbwarn "If the build fails, install 32-bit developer packages." + bbwarn "If you are using 32-bit binaries, the 32-bit libpseudo is NOT optional." +} + +# Two below are the same +# If necessary compile for the alternative machine arch. This is only +# necessary in a native build. +do_compile_prepend_class-native () { + maybe_make32 + if $make32; then + # We need the 32-bit libpseudo on a 64-bit machine... + # Note that this is not well-tested outside of x86/x86_64. + + # if we're being rebuilt due to a dependency change, we need to make sure + # everything is clean before we configure and build -- if we haven't previously + # built this will fail and be ignored. + make ${MAKEOPTS} distclean || : + + ./configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --bits=32 --without-rpath + save_traps=$(trap) + trap 'warn_32bit_missing' 0 + oe_runmake ${MAKEOPTS} libpseudo + eval "$save_traps" + # prevent it from removing the lib, but remove everything else + make 'LIB=foo' ${MAKEOPTS} distclean + fi +} + +do_compile_prepend_class-nativesdk () { + maybe_make32 + if $make32; then + # We need the 32-bit libpseudo on a 64-bit machine. + # Note that this is not well-tested outside of x86/x86_64. + ./configure ${PSEUDO_EXTRA_OPTS} --prefix=${prefix} --libdir=${prefix}/lib/pseudo/lib --with-sqlite-lib=${baselib} --with-sqlite=${STAGING_DIR_TARGET}${exec_prefix} --bits=32 --without-rpath + oe_runmake ${MAKEOPTS} libpseudo + # prevent it from removing the lib, but remove everything else + make 'LIB=foo' ${MAKEOPTS} distclean + fi +} + +do_install () { + oe_runmake 'DESTDIR=${D}' ${MAKEOPTS} 'LIB=lib/pseudo/lib$(MARK64)' install +} + +# Two below are the same +# If necessary install for the alternative machine arch. This is only +# necessary in a native build. +do_install_append_class-native () { + maybe_make32 + if $make32; then + mkdir -p ${D}${prefix}/lib/pseudo/lib + cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. + fi +} + +do_install_append_class-nativesdk () { + maybe_make32 + if $make32; then + mkdir -p ${D}${prefix}/lib/pseudo/lib + cp lib/pseudo/lib/libpseudo.so ${D}${prefix}/lib/pseudo/lib/. + fi +} + +BBCLASSEXTEND = "native nativesdk" diff --git a/meta/recipes-devtools/pseudo/pseudo_1.5.1.bb b/meta/recipes-devtools/pseudo/pseudo_1.5.1.bb new file mode 100644 index 0000000000..8d562ecbf7 --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo_1.5.1.bb @@ -0,0 +1,20 @@ +require pseudo.inc + +PR = "r5" + +SRC_URI = " \ + http://www.yoctoproject.org/downloads/${BPN}/${BPN}-${PV}.tar.bz2 \ + file://0001-pseudo_has_unload-add-function.patch \ + file://shutdownping.patch \ + file://pseudo-1.5.1-install-directory-mode.patch \ + file://pseudo-fchmodat-permissions.patch \ +" + +SRC_URI_append_class-nativesdk = " file://symver.patch" + +SRC_URI_append_class-native = " file://symver.patch" + +SRC_URI[md5sum] = "5ec67c7bff5fe68c56de500859c19172" +SRC_URI[sha256sum] = "3b896f592f4d568569bd02323fad2d6b8c398e16ca36ee5a8947d2ff6c1d3d52" + +PSEUDO_EXTRA_OPTS ?= "--enable-force-async" diff --git a/meta/recipes-devtools/pseudo/pseudo_1.6.2.bb b/meta/recipes-devtools/pseudo/pseudo_1.6.2.bb new file mode 100644 index 0000000000..261c8d3abd --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo_1.6.2.bb @@ -0,0 +1,22 @@ +require pseudo.inc + +SRC_URI = " \ + http://www.yoctoproject.org/downloads/${BPN}/${BPN}-${PV}.tar.bz2 \ + file://0001-pseudo_client.c-protect-pwd_lck-against-magic.patch \ + file://0002-pseudo_util-modify-interface-to-pseudo_etc_file.patch \ + file://0003-pseudo_client.c-support-multiple-directories-in-PSEU.patch \ + file://fallback-passwd \ + file://fallback-group \ +" + +SRC_URI[md5sum] = "4d7b4f9d1b4aafa680ce94a5a9a52f1f" +SRC_URI[sha256sum] = "c72be92689511ced7c419149c6aaa1b1a9e4dfc6409d1f16ab72cc35bc1e376a" + +PSEUDO_EXTRA_OPTS ?= "--enable-force-async --without-passwd-fallback" + +do_install_append_class-native () { + install -d ${D}${sysconfdir} + # The fallback files should never be modified + install -m 444 ${WORKDIR}/fallback-passwd ${D}${sysconfdir}/passwd + install -m 444 ${WORKDIR}/fallback-group ${D}${sysconfdir}/group +} diff --git a/meta/recipes-devtools/pseudo/pseudo_git.bb b/meta/recipes-devtools/pseudo/pseudo_git.bb new file mode 100644 index 0000000000..8c6f06ab46 --- /dev/null +++ b/meta/recipes-devtools/pseudo/pseudo_git.bb @@ -0,0 +1,11 @@ +require pseudo.inc + +SRCREV = "0dc29e7c67f25d0978a7da5cd8965514912c5b36" +PV = "1.6.2+git${SRCPV}" + +DEFAULT_PREFERENCE = "-1" + +SRC_URI = "git://git.yoctoproject.org/pseudo" + +S = "${WORKDIR}/git" + -- cgit v1.2.3-54-g00ecf