public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/
Date: Sat,  8 Mar 2014 05:51:16 +0000 (UTC)	[thread overview]
Message-ID: <1392585264.8a2857f3ced8f191b56a3e690cacf03a3a745d67.vapier@gentoo> (raw)

commit:     8a2857f3ced8f191b56a3e690cacf03a3a745d67
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 16 21:14:24 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> 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        - <solar@gentoo.org>
  * Copyright 2005-2011 Mike Frysinger  - <vapier@gentoo.org>
@@ -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        - <solar@gentoo.org>
  * Copyright 2005-2011 Mike Frysinger  - <vapier@gentoo.org>
@@ -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        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -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        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -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        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -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        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -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;
 		}
 	}


             reply	other threads:[~2014-03-08  5:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-08  5:51 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-03-08  5:51 [gentoo-commits] proj/portage-utils:master commit in: /, libq/ Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-10  8:45 Mike Frysinger
2014-03-21  5:32 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2016-02-14  1:26 Mike Frysinger
2016-02-14  1:26 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2018-05-18 16:58 Fabian Groffen
2019-05-02 15:48 Fabian Groffen
2019-05-06 17:33 Fabian Groffen
2019-05-07  6:19 Fabian Groffen
2019-07-14 13:09 Fabian Groffen
2019-11-15 13:52 Fabian Groffen
2020-01-01 17:54 Fabian Groffen
2020-01-04 19:48 Fabian Groffen
2020-01-05 16:08 Fabian Groffen
2020-05-16 18:27 Fabian Groffen
2024-01-02  7:57 Fabian Groffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392585264.8a2857f3ced8f191b56a3e690cacf03a3a745d67.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox