From patchwork Thu Mar 20 19:37:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 108657 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 491DB3857C7F for ; Thu, 20 Mar 2025 19:39:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 491DB3857C7F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HgDcJiZS X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 5C5513857C6C for ; Thu, 20 Mar 2025 19:37:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C5513857C6C Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5C5513857C6C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742499454; cv=none; b=L3ParUwXZSnvVBlLOvK0M0J37m3EHVTga7kuco5vmscoeC0ISKP0W00AgkAfcob1iOHbktuF6aZb5+0Q1I+6eRvd4nzvDl4B7pJhU6otZBs06saQYXjqh3WNltBEGxg+lOoXOFR7T1Rvk5FFYQmWhxTQR7boQuE8/bHck9h4c9o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1742499454; c=relaxed/simple; bh=WIqt1i+pZmqtm3gQjp9odBBX3Lb0cuzy82vA8yzK5EU=; h=DKIM-Signature:Date:Message-Id:From:To:Subject; b=ahOZ/J7QW8kDlIO3Vq/eGYHLvsg6qsBsPp9UNGxO93U03YVu8ujUSw3MCgv2Bf+r3NdwIN2KgWbze5WRo+AhVhtpR+2jG4RXzGunWlzRg69mRz505c7fkSVK9n9wfamVYdZHYuRGHxv1fUxGXl5+oa+rzMC8Dls2qyfX57Ranrc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5C5513857C6C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742499454; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type; bh=m00XOQYgzv+K3BeW02e3HRmMcBkTj4QJRlQn3UH6plk=; b=HgDcJiZSJN/yHR6rVX2mjBckAf1KVapqHD6XECHv6JgWtogzhiEauzYzX9+Sn6lr6b+UEa 3DBujc9ZTd8VsryJgBhrvqJ7LMIO3JONXBu2Dn+k8dzaMqk1n5jf5BH9dyreKfHxuH/YZL i2yB3gX6GUEVCZXBIeAi/J7BFR25CEc= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-595-QDvOo4iFNE2BqHffdmtCSg-1; Thu, 20 Mar 2025 15:37:32 -0400 X-MC-Unique: QDvOo4iFNE2BqHffdmtCSg-1 X-Mimecast-MFC-AGG-ID: QDvOo4iFNE2BqHffdmtCSg_1742499452 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1FF66190308B for ; Thu, 20 Mar 2025 19:37:32 +0000 (UTC) Received: from greed.delorie.com (unknown [10.22.88.99]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C5A17195609D for ; Thu, 20 Mar 2025 19:37:31 +0000 (UTC) Received: from greed.delorie.com.redhat.com (localhost [127.0.0.1]) by greed.delorie.com (8.16.1/8.16.1) with ESMTP id 52KJbT8a708615 for ; Thu, 20 Mar 2025 15:37:29 -0400 Date: Thu, 20 Mar 2025 15:37:29 -0400 Message-Id: From: DJ Delorie To: libc-alpha@sourceware.org Subject: [patch v1] add ptmx support to test-container X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZZoNwxepfF8T-KsCHm4-kVNNvTYOzqBuQcrvzLb8ASw_1742499452 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_W, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org diff --git a/support/Makefile b/support/Makefile index 59a9974539..2887cc7fa9 100644 --- a/support/Makefile +++ b/support/Makefile @@ -325,6 +325,7 @@ tests = \ README-testing \ tst-support-namespace \ tst-support-open-dev-null-range \ + tst-support-openpty \ tst-support-process_state \ tst-support_blob_repeat \ tst-support_capture_subprocess \ @@ -346,6 +347,10 @@ tests = \ tst-xsigstack \ # tests +tests-container = \ + tst-support-openpty-c \ + # tests-container + ifeq ($(run-built-tests),yes) tests-special = \ $(objpfx)tst-support_record_failure-2.out diff --git a/support/test-container.c b/support/test-container.c index 79d3189e2f..a641250079 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -1151,6 +1151,9 @@ main (int argc, char **argv) devmount (new_root_path, "null"); devmount (new_root_path, "zero"); devmount (new_root_path, "urandom"); +#ifdef __linux__ + devmount (new_root_path, "ptmx"); +#endif /* We're done with the "old" root, switch to the new one. */ if (chroot (new_root_path) < 0) @@ -1217,6 +1220,14 @@ main (int argc, char **argv) maybe_xmkdir ("/tmp", 0755); +#ifdef __linux__ + maybe_xmkdir ("/dev/pts", 0777); + if (mount ("/dev/pts", "/dev/pts", "devpts", 0, "newinstance,ptmxmode=0666,mode=0666") < 0) + FAIL_EXIT1 ("can't mount /dev/pts: %m\n"); + if (mount ("/dev/pts/ptmx", "/dev/ptmx", "", MS_BIND | MS_REC, NULL) < 0) + FAIL_EXIT1 ("can't mount /dev/ptmx\n"); +#endif + if (require_pidns) { /* Now that we're pid 1 (effectively "root") we can mount /proc */ diff --git a/support/tst-support-openpty-c.c b/support/tst-support-openpty-c.c new file mode 100644 index 0000000000..0a6a428fc3 --- /dev/null +++ b/support/tst-support-openpty-c.c @@ -0,0 +1,2 @@ +/* Same test, but in a test-container. */ +#include "tst-support-openpty.c" diff --git a/support/tst-support-openpty.c b/support/tst-support-openpty.c new file mode 100644 index 0000000000..b0e3448fa1 --- /dev/null +++ b/support/tst-support-openpty.c @@ -0,0 +1,49 @@ +/* Basic test for support_openpty support in test-container. + Copyright (C) 2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include +#include + +/* Note: the purpose of this test isn't to test if ptys function + correctly, but only to verify that test-container's support for + them is correct. The many checks in support_openpty.c are + sufficient for this. */ + +int +do_test(void) +{ + int outer, inner; + char *name; + struct termios term; + struct winsize win; + + cfmakeraw (&term); + win.ws_row = 24; + win.ws_col = 80; + + support_openpty (&outer, &inner, &name, &term, &win); + + return 0; +} + +#include