{"id":2223679,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2223679/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/patch/20260416005603.22427-2-wegao@suse.com/","project":{"id":59,"url":"http://patchwork.ozlabs.org/api/1.1/projects/59/?format=json","name":"Linux Test Project development","link_name":"ltp","list_id":"ltp.lists.linux.it","list_email":"ltp@lists.linux.it","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260416005603.22427-2-wegao@suse.com>","date":"2026-04-16T00:55:22","name":"[v8,1/2] lib: New library function tst_get_free_uid","commit_ref":null,"pull_url":null,"state":"needs-review-ack","archived":false,"hash":"5922c9562177c84a0f80be67393323111339f9b3","submitter":{"id":85577,"url":"http://patchwork.ozlabs.org/api/1.1/people/85577/?format=json","name":"Wei Gao","email":"wegao@suse.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ltp/patch/20260416005603.22427-2-wegao@suse.com/mbox/","series":[{"id":500061,"url":"http://patchwork.ozlabs.org/api/1.1/series/500061/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/list/?series=500061","date":"2026-04-16T00:55:21","name":"open16: allow restricted O_CREAT of FIFOs and regular files","version":8,"mbox":"http://patchwork.ozlabs.org/series/500061/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2223679/comments/","check":"warning","checks":"http://patchwork.ozlabs.org/api/patches/2223679/checks/","tags":{},"headers":{"Return-Path":"<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>","X-Original-To":["incoming@patchwork.ozlabs.org","ltp@lists.linux.it"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ltp@picard.linux.it"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=lists.linux.it header.i=@lists.linux.it\n header.a=rsa-sha256 header.s=picard header.b=RtLVL16v;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256\n header.s=google header.b=ZfFfIfTq;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)"],"Received":["from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fx02Y32g1z1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 10:56:37 +1000 (AEST)","from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 112E43E71F9\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 16 Apr 2026 02:56:35 +0200 (CEST)","from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it\n [IPv6:2001:4b78:1:20::3])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id C01633E5DBA\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 02:56:09 +0200 (CEST)","from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n [IPv6:2a00:1450:4864:20::429])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 036641A0025F\n for <ltp@lists.linux.it>; Thu, 16 Apr 2026 02:56:08 +0200 (CEST)","by mail-wr1-x429.google.com with SMTP id\n ffacd0b85a97d-43d73352cf2so3646670f8f.1\n for <ltp@lists.linux.it>; Wed, 15 Apr 2026 17:56:08 -0700 (PDT)","from localhost ([2a07:de40:b240:0:2ad6:ed42:2ad6:ed42])\n by smtp.gmail.com with UTF8SMTPSA id\n ffacd0b85a97d-43ead3e89ddsm8742710f8f.30.2026.04.15.17.56.07\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 15 Apr 2026 17:56:07 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it;\n i=@lists.linux.it; q=dns/txt; s=picard; t=1776300995; h=to : date :\n message-id : in-reply-to : references : mime-version : subject :\n list-id : list-unsubscribe : list-archive : list-post : list-help :\n list-subscribe : from : reply-to : content-type :\n content-transfer-encoding : sender : from;\n bh=CW7OrP7WiIAbSO2ZrN0BAtBMohc0i7ydsJRF5dh/TSI=;\n b=RtLVL16vdvjzhpMhQZtZKONRqEUWwnMLBA4YPbHS0n09je64p3FaZP2RRxKiAX96w03sN\n IyRTjsdsQJCsTNNEm3YXFjPXVRkKlb7CetpaYzKGHU+AVpnzG9Anjj+642OBI60XB5witor\n GGKtrN3OQPFBXJnDS///Nb5Qb/h+ctI=","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=suse.com; s=google; t=1776300968; x=1776905768; darn=lists.linux.it;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=IXG96hzdr8AsF7J2pEPmsFfr2LG6zdtRgzLGip5/aw0=;\n b=ZfFfIfTqlNwJemYAtKTOMx6q6RvCJDSy2imPCHwhz3giPaZ+oQEwiQuoKHSVx1nys+\n oempRfr2rVvs8iGbPy2V974XYawPC5XOhz/pt2pp3/0hMjJmUW8FBwzJh7ql79Ze4ds2\n 2RnyOxLAr6VQpdtZLk7dkbaD/SW1Ewntcw/hteRJa5PvR41XfwGtYBvz5Fiy4MlNLUFy\n 5Y2JCx/OStX9iJHXbdEyjLkB7YgLAVcTFNkCZOllzGHag7r6XQmeXsb6f+WWlsOmjLkS\n jGsspkUVBwzAUvB5nbcjxuC0eH2r0V85QlgHDIa/CvfPYKk7+12llvbRoG3UJiSrA0Hd\n J/Mg=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1776300968; x=1776905768;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=IXG96hzdr8AsF7J2pEPmsFfr2LG6zdtRgzLGip5/aw0=;\n b=RAY3khiUKCslGc5joKHo+63Y7qyyQc2usAFdoPulJNmx2sHp3AjrlehnlxB0MdRwUA\n PsVTbGM6YBX8/XFuP67c1okxU7SPNKMGlyILL/Uw6hRp9R9Qz8FF3IErcMshn5lRaOLS\n ADH3m4xS62PNGKl2PVchxqHWdQAffTwsN0c74oQAznRvGUXtORI5pdYPfB6RwXvLTAj2\n dERpp9ZPfw5dAOTgs8R0/YUyVSIeAzz6FiwQoAyL6L0Eo0ukdqDjSFvVfWwc6bMjJ3mS\n QPqt9ZgDHUnsgXN9qvAMvFmRzpUU7gq5haiPcZ/+/L2lLHmqqH2rCQwLfRjs2iez/I+C\n vB+g==","X-Gm-Message-State":"AOJu0YyqWfau6lGUNaxkyzptfyf2PPo2Uvjv4mEFG+c4P1WRddzsoIWz\n r6ta7QBtS/85H9FHDvSehwhKo80MSMz47x8ieGRIizZHAMF8cE65F35+way84OGrp3EKcgtFk1f\n 8aQ0=","X-Gm-Gg":"AeBDieuqnzgnpRGfCMQdgRD3WZ4VSfkTgYUbRBCD7rIYWRfkVJzrEfdbhvbgNO8UlZe\n 0mEioP3tAn6r7phww0q2MmoH1V6uIx/V7yaWtu/otPaxhGKHZLHo/Bs1idwNFJg7OJ59leptD+L\n pQRuN/W/Em9OoHrifzVEvbPbuUxykXdFX53w6/Sw/AWiSlskt2/739/GB9PAZ2+i/BkuHkV4Prh\n Z+8HswCC3wQDsKSkSL3WS5bJ3SjEOO5RsgKqEy3LlmWJyzRKZrpOGuMDP5p0t1EDVC4mENX3teX\n RVpyvRXDy9Svk4KO4Bdfz5LRBrN8QbCdPRTOW3+TCLGgKZIx21YqCVlFtiuV7PDB89bDtjCok8P\n 6dk+7OrLDS4VRvxbtzM03oVWWFqTtNwTenOmGABmLD1V3n0MEwFTNCBkw/WKWg2VjxBLx9Y8H75\n a4SE3q2BGCBA5wxlJt/VUCTw==","X-Received":"by 2002:a05:6000:250c:b0:43e:a8ad:975a with SMTP id\n ffacd0b85a97d-43ea8ad9a92mr10985651f8f.4.1776300968014;\n Wed, 15 Apr 2026 17:56:08 -0700 (PDT)","To":"ltp@lists.linux.it","Date":"Thu, 16 Apr 2026 00:55:22 +0000","Message-ID":"<20260416005603.22427-2-wegao@suse.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260416005603.22427-1-wegao@suse.com>","References":"<20260415103812.21999-2-wegao@suse.com>\n <20260416005603.22427-1-wegao@suse.com>","MIME-Version":"1.0","X-Spam-Status":"No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on in-3.smtp.seeweb.it","X-Virus-Scanned":"clamav-milter 1.0.9 at in-3.smtp.seeweb.it","X-Virus-Status":"Clean","Subject":"[LTP] [PATCH v8 1/2] lib: New library function tst_get_free_uid","X-BeenThere":"ltp@lists.linux.it","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux Test Project <ltp.lists.linux.it>","List-Unsubscribe":"<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>","List-Archive":"<http://lists.linux.it/pipermail/ltp/>","List-Post":"<mailto:ltp@lists.linux.it>","List-Help":"<mailto:ltp-request@lists.linux.it?subject=help>","List-Subscribe":"<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>","From":"Wei Gao via ltp <ltp@lists.linux.it>","Reply-To":"Wei Gao <wegao@suse.com>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it","Sender":"\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"},"content":"Add tst_get_free_uid() to dynamically find unused UIDs for tests.\n\nSigned-off-by: Wei Gao <wegao@suse.com>\n---\n include/tst_uid.h |  7 +++++--\n lib/tst_uid.c     | 26 ++++++++++++++++++++++++++\n 2 files changed, 31 insertions(+), 2 deletions(-)","diff":"diff --git a/include/tst_uid.h b/include/tst_uid.h\nindex 2237ddcbf..394cb3edc 100644\n--- a/include/tst_uid.h\n+++ b/include/tst_uid.h\n@@ -8,10 +8,13 @@\n #include <sys/types.h>\n \n /*\n- * Find unassigned gid. The skip argument can be used to ignore e.g. the main\n+ * Find unassigned uid/gid. The skip argument can be used to ignore e.g. the main\n  * group of a specific user in case it's not listed in the group file. If you\n- * do not need to skip any specific gid, simply set it to 0.\n+ * do not need to skip any specific id, simply set it to 0.\n  */\n+uid_t tst_get_free_uid_(const char *file, const int lineno, uid_t skip);\n+#define tst_get_free_uid(skip) tst_get_free_uid_(__FILE__, __LINE__, (skip))\n+\n gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip);\n #define tst_get_free_gid(skip) tst_get_free_gid_(__FILE__, __LINE__, (skip))\n \ndiff --git a/lib/tst_uid.c b/lib/tst_uid.c\nindex af4ef8cf7..deff17085 100644\n--- a/lib/tst_uid.c\n+++ b/lib/tst_uid.c\n@@ -5,6 +5,7 @@\n \n #include <sys/types.h>\n #include <grp.h>\n+#include <pwd.h>\n #include <errno.h>\n \n #define TST_NO_DEFAULT_MAIN\n@@ -12,6 +13,31 @@\n #include \"tst_uid.h\"\n \n #define MAX_GID 32767\n+#define MAX_UID 32767\n+\n+uid_t tst_get_free_uid_(const char *file, const int lineno, uid_t skip)\n+{\n+\tuid_t ret;\n+\n+\terrno = 0;\n+\n+\tfor (ret = 1; ret < MAX_UID; ret++) {\n+\t\tif (ret == skip || getpwuid(ret))\n+\t\t\tcontinue;\n+\n+\t\tif (errno == 0 || errno == ENOENT || errno == ESRCH) {\n+\t\t\ttst_res_(file, lineno, TINFO | TERRNO,\n+\t\t\t\t\"Found unused UID %d\", (int)ret);\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\ttst_brk_(file, lineno, TBROK|TERRNO, \"User ID lookup failed\");\n+\t\treturn (uid_t)-1;\n+\t}\n+\n+\ttst_brk_(file, lineno, TBROK, \"No free user ID found\");\n+\treturn (uid_t)-1;\n+}\n \n gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip)\n {\n","prefixes":["v8","1/2"]}