From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 477D11391ED for ; Sat, 8 Mar 2014 05:51:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D7670E0B11; Sat, 8 Mar 2014 05:51:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 1D2AFE0B0B for ; Sat, 8 Mar 2014 05:51:20 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 83F8733FB91 for ; Sat, 8 Mar 2014 05:51:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 2A13C188F1 for ; Sat, 8 Mar 2014 05:51:16 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1392585264.8a2857f3ced8f191b56a3e690cacf03a3a745d67.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: TODO libq/profile.c libq/scandirat.c libq/vdb.c libq/xmkdir.c porting.h qmerge.c qtbz2.c qxpak.c X-VCS-Directories: / libq/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 8a2857f3ced8f191b56a3e690cacf03a3a745d67 X-VCS-Branch: master Date: Sat, 8 Mar 2014 05:51:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b741eb8c-030b-44d9-8fff-fe4312ffb56b X-Archives-Hash: b7136cd9da95085d490a8b4e59684f58 commit: 8a2857f3ced8f191b56a3e690cacf03a3a745d67 Author: Mike Frysinger gentoo org> AuthorDate: Sun Feb 16 21:14:24 2014 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Feb 16 21:14:24 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=8a2857f3 start using O_PATH --- TODO | 3 +-- libq/profile.c | 2 +- libq/scandirat.c | 3 ++- libq/vdb.c | 12 ++++++++---- libq/xmkdir.c | 1 + porting.h | 5 ++++- qmerge.c | 13 +++++++------ qtbz2.c | 6 +++--- qxpak.c | 6 +++--- 9 files changed, 30 insertions(+), 21 deletions(-) diff --git a/TODO b/TODO index 5f1f382..4bb86fb 100644 --- a/TODO +++ b/TODO @@ -11,8 +11,6 @@ - speed up queue structure ... append walks the whole list -- use O_PATH with fd's that are only used to open other files - - qmerge - dep resolver needs spanktastic love. - needs safe deleting (merge in place rather than unmerge;merge) @@ -35,6 +33,7 @@ foo-(1234)_alpha(56789) - these limits should not be an issue for all practical purposes - need to handle USE deps like: cat/pkg-123[foo(+)] + - show support slots like: qmerge -U automake:1.12 - qcache: - need to convert it to new metadata/md5 style diff --git a/libq/profile.c b/libq/profile.c index 707695d..75f3cb0 100644 --- a/libq/profile.c +++ b/libq/profile.c @@ -10,7 +10,7 @@ q_profile_walk_at(int dir_fd, const char *dir, const char *file, char *buf; /* Pop open this profile dir */ - subdir_fd = openat(dir_fd, dir, O_RDONLY|O_CLOEXEC); + subdir_fd = openat(dir_fd, dir, O_RDONLY|O_CLOEXEC|O_PATH); if (subdir_fd < 0) return data; diff --git a/libq/scandirat.c b/libq/scandirat.c index 76a5d4a..0a84828 100644 --- a/libq/scandirat.c +++ b/libq/scandirat.c @@ -1,7 +1,7 @@ /* * Copyright 2005-2011 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.7 2013/11/17 10:26:53 grobian Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/scandirat.c,v 1.8 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2011 Mike Frysinger - @@ -29,6 +29,7 @@ static int scandirat(int dir_fd, const char *dir, struct dirent ***dirlist, DIR *dirp; struct dirent *de, **ret; + /* Cannot use O_PATH as we want to use fdopendir() */ fd = openat(dir_fd, dir, O_RDONLY|O_CLOEXEC); if (fd == -1) return -1; diff --git a/libq/vdb.c b/libq/vdb.c index 156e088..1100405 100644 --- a/libq/vdb.c +++ b/libq/vdb.c @@ -1,7 +1,7 @@ /* * Copyright 2005-2011 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/vdb.c,v 1.5 2012/10/28 06:27:59 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/libq/vdb.c,v 1.6 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2011 Mike Frysinger - @@ -24,7 +24,7 @@ _q_static q_vdb_ctx *q_vdb_open(/*const char *sroot, const char *svdb*/void) if (!sroot) sroot = portroot; - ctx->portroot_fd = open(sroot, O_RDONLY|O_CLOEXEC); + ctx->portroot_fd = open(sroot, O_RDONLY|O_CLOEXEC|O_PATH); if (ctx->portroot_fd == -1) { warnp("could not open root: %s", sroot); goto f_error; @@ -36,6 +36,7 @@ _q_static q_vdb_ctx *q_vdb_open(/*const char *sroot, const char *svdb*/void) svdb++; if (*svdb == '\0') svdb = "."; + /* Cannot use O_PATH as we want to use fdopendir() */ ctx->vdb_fd = openat(ctx->portroot_fd, svdb, O_RDONLY|O_CLOEXEC); if (ctx->vdb_fd == -1) { warnp("could not open vdb: %s (in root %s)", svdb, sroot); @@ -114,6 +115,7 @@ _q_static q_vdb_cat_ctx *q_vdb_open_cat(q_vdb_ctx *ctx, const char *name) int fd; DIR *dir; + /* Cannot use O_PATH as we want to use fdopendir() */ fd = openat(ctx->vdb_fd, name, O_RDONLY|O_CLOEXEC); if (fd == -1) return NULL; @@ -194,9 +196,10 @@ _q_static q_vdb_pkg_ctx *q_vdb_open_pkg(q_vdb_cat_ctx *cat_ctx, const char *name q_vdb_pkg_ctx *pkg_ctx; int fd; - fd = openat(cat_ctx->fd, name, O_RDONLY|O_CLOEXEC); +// fd = openat(cat_ctx->fd, name, O_RDONLY|O_CLOEXEC|O_PATH); if (fd == -1) return NULL; + fd = -1; pkg_ctx = xmalloc(sizeof(*pkg_ctx)); pkg_ctx->name = name; @@ -251,7 +254,8 @@ _q_static FILE *q_vdb_pkg_fopenat(q_vdb_pkg_ctx *pkg_ctx, const char *file, _q_static void q_vdb_close_pkg(q_vdb_pkg_ctx *pkg_ctx) { - close(pkg_ctx->fd); + if (pkg_ctx->fd != -1) + close(pkg_ctx->fd); free(pkg_ctx); } diff --git a/libq/xmkdir.c b/libq/xmkdir.c index eb0123a..600e6d0 100644 --- a/libq/xmkdir.c +++ b/libq/xmkdir.c @@ -43,6 +43,7 @@ _q_static int rm_rf_at(int dfd, const char *path) DIR *dir; struct dirent *de; + /* Cannot use O_PATH as we want to use fdopendir() */ subdfd = openat(dfd, path, O_RDONLY|O_CLOEXEC|O_NOFOLLOW); if (subdfd < 0) return -1; diff --git a/porting.h b/porting.h index 8c93f05..f36d6b7 100644 --- a/porting.h +++ b/porting.h @@ -1,7 +1,7 @@ /* * Copyright 2005-2013 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/porting.h,v 1.1 2013/09/29 22:42:36 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/porting.h,v 1.2 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2008 Ned Ludd - * Copyright 2005-2013 Mike Frysinger - @@ -66,6 +66,9 @@ #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif +#ifndef O_PATH +#define O_PATH 0 +#endif #ifndef CONFIG_EPREFIX #define CONFIG_EPREFIX "/" diff --git a/qmerge.c b/qmerge.c index 40d4139..5ec9be8 100644 --- a/qmerge.c +++ b/qmerge.c @@ -1,7 +1,7 @@ /* * Copyright 2005-2010 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = { COMMON_OPTS_HELP }; -static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $"; +static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $"; #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge")) char search_pkgs = 0; @@ -237,7 +237,7 @@ _q_static char *best_version(const char *catname, const char *pkgname) /* Make sure these dirs exist before we try walking them */ switch (vdb_check) { case 1: { - int fd = open(portroot, O_RDONLY|O_CLOEXEC); + int fd = open(portroot, O_RDONLY|O_CLOEXEC|O_PATH); if (fd >= 0) { /* skip leading slash */ vdb_check = faccessat(fd, portvdb + 1, X_OK, 0); @@ -483,10 +483,11 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst, ret = -1; /* Get handles to these subdirs */ + /* Cannot use O_PATH as we want to use fdopendir() */ subfd_src = openat(fd_src, src, O_RDONLY|O_CLOEXEC); if (subfd_src < 0) return ret; - subfd_dst = openat(fd_dst, dst, O_RDONLY|O_CLOEXEC); + subfd_dst = openat(fd_dst, dst, O_RDONLY|O_CLOEXEC|O_PATH); if (subfd_dst < 0) { close(subfd_src); return ret; @@ -1038,7 +1039,7 @@ pkg_unmerge(const char *cat, const char *pkgname, queue *keep) return 0; /* Get a handle to the root to play with */ - portroot_fd = open(portroot, O_RDONLY | O_CLOEXEC); + portroot_fd = open(portroot, O_RDONLY|O_CLOEXEC|O_PATH); if (portroot_fd == -1) { warnp("unable to read %s", portroot); goto done; @@ -1048,7 +1049,7 @@ pkg_unmerge(const char *cat, const char *pkgname, queue *keep) /* Note: This vdb_path must be absolute since we use it in pkg_run_func() */ xasprintf(&vdb_path, "%s%s/%s/%s/", portroot, portvdb, cat, pkgname); xasprintf(&T, "%stemp", vdb_path); - vdb_fd = openat(portroot_fd, vdb_path, O_RDONLY | O_CLOEXEC); + vdb_fd = openat(portroot_fd, vdb_path, O_RDONLY|O_CLOEXEC|O_PATH); if (vdb_fd == -1) { warnp("unable to read %s", vdb_path); goto done; diff --git a/qtbz2.c b/qtbz2.c index 24d75bf..4f9f24c 100644 --- a/qtbz2.c +++ b/qtbz2.c @@ -1,7 +1,7 @@ /* * Copyright 2005-2010 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/qtbz2.c,v 1.21 2012/11/17 18:44:58 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qtbz2.c,v 1.22 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -46,7 +46,7 @@ static const char * const qtbz2_opts_help[] = { "Write files to stdout", COMMON_OPTS_HELP }; -static const char qtbz2_rcsid[] = "$Id: qtbz2.c,v 1.21 2012/11/17 18:44:58 vapier Exp $"; +static const char qtbz2_rcsid[] = "$Id: qtbz2.c,v 1.22 2014/02/16 21:14:24 vapier Exp $"; #define qtbz2_usage(ret) usage(ret, QTBZ2_FLAGS, qtbz2_long_opts, qtbz2_opts_help, lookup_applet_idx("qtbz2")) static char tbz2_stdout = 0; @@ -263,7 +263,7 @@ int qtbz2_main(int argc, char **argv) case 'd': if (dir_fd != AT_FDCWD) err("Only use -d once"); - dir_fd = open(optarg, O_RDONLY|O_CLOEXEC); + dir_fd = open(optarg, O_RDONLY|O_CLOEXEC|O_PATH); break; } } diff --git a/qxpak.c b/qxpak.c index 989dc97..2d1a7ad 100644 --- a/qxpak.c +++ b/qxpak.c @@ -1,7 +1,7 @@ /* * Copyright 2005-2010 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 - * $Header: /var/cvsroot/gentoo-projects/portage-utils/qxpak.c,v 1.26 2013/04/21 04:28:10 vapier Exp $ + * $Header: /var/cvsroot/gentoo-projects/portage-utils/qxpak.c,v 1.27 2014/02/16 21:14:24 vapier Exp $ * * Copyright 2005-2010 Ned Ludd - * Copyright 2005-2010 Mike Frysinger - @@ -46,7 +46,7 @@ static const char * const qxpak_opts_help[] = { "Write files to stdout", COMMON_OPTS_HELP }; -static const char qxpak_rcsid[] = "$Id: qxpak.c,v 1.26 2013/04/21 04:28:10 vapier Exp $"; +static const char qxpak_rcsid[] = "$Id: qxpak.c,v 1.27 2014/02/16 21:14:24 vapier Exp $"; #define qxpak_usage(ret) usage(ret, QXPAK_FLAGS, qxpak_long_opts, qxpak_opts_help, lookup_applet_idx("qxpak")) typedef struct { @@ -397,7 +397,7 @@ int qxpak_main(int argc, char **argv) case 'd': if (dir_fd != AT_FDCWD) err("Only use -d once"); - dir_fd = open(optarg, O_RDONLY|O_CLOEXEC); + dir_fd = open(optarg, O_RDONLY|O_CLOEXEC|O_PATH); break; } }