From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F177138359 for ; Sun, 4 Oct 2020 11:54:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 99FD8E088C; Sun, 4 Oct 2020 11:54:09 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7AB4AE088C for ; Sun, 4 Oct 2020 11:54:09 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3C624340B23 for ; Sun, 4 Oct 2020 11:54:08 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A8FAA26 for ; Sun, 4 Oct 2020 11:54:06 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1601812333.a29346b666decbba87f1d9cf56f7f72de485c343.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: a29346b666decbba87f1d9cf56f7f72de485c343 X-VCS-Branch: master Date: Sun, 4 Oct 2020 11:54:06 +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-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 41954c16-5a84-45de-98e9-de0407a759db X-Archives-Hash: 983ed5f3b3130fd863b7e1fb0fb235a7 commit: a29346b666decbba87f1d9cf56f7f72de485c343 Author: Fabian Groffen gentoo org> AuthorDate: Sun Oct 4 11:52:13 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sun Oct 4 11:52:13 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a29346b6 qlop: return sandbox piggybacking method of finding running merges Because sandbox doesn't seem as dead as it was pronounced a while ago, bring back support in qlop, since it is the easiest way to detect running merges without any special privileges necessary. Signed-off-by: Fabian Groffen gentoo.org> qlop.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/qlop.c b/qlop.c index 316c9b0..dce46f2 100644 --- a/qlop.c +++ b/qlop.c @@ -1197,6 +1197,8 @@ static array_t *probe_proc(array_t *atoms) depend_atom *atom; DECLARE_ARRAY(ret_atoms); size_t i; + char *cmdline = NULL; + size_t cmdlinesize = 0; /* /proc//path/<[0-9]+link> * /proc//fd/<[0-9]+link> */ @@ -1218,6 +1220,33 @@ static array_t *probe_proc(array_t *atoms) } pid = d->d_name; + + /* first try old-fashioned (good old) sandbox approach; this + * one may not have a long life in Gentoo any more, but for + * now it's still being used quite a lot, and the advantage + * is that it doesn't require root access, for cmdline can + * be read by anyone */ + snprintf(npath, sizeof(npath), "/proc/%s/cmdline", pid); + if (eat_file(npath, &cmdline, &cmdlinesize)) { + if (cmdlinesize > 0 && cmdline[0] == '[' && + (p = strchr(cmdline, ']')) != NULL && + strncmp(p, "] sandbox", sizeof("] sandbox") - 1) == 0) + { + *p = '\0'; + atom = atom_explode(cmdline + 1); + + if (atom != NULL) { + if (atom->CATEGORY == NULL || atom->P == NULL) { + atom_implode(atom); + } else { + xarraypush_ptr(ret_atoms, atom); + continue; + } + } + } + } + + /* now try and see if Portage opened a build log somewhere */ snprintf(npath, sizeof(npath), "/proc/%s/%s", pid, subdir); if ((linkslen = scandir(npath, &links, NULL, NULL)) > 0) { for (li = 0; li < linkslen; li++) {