From nobody Sat Dec 11 17:02:36 2021 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8BB6518DC4BF for ; Sat, 11 Dec 2021 17:02:54 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JBDbx5p7Gz4Yq8; Sat, 11 Dec 2021 17:02:53 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-ot1-f45.google.com with SMTP id 47-20020a9d0332000000b005798ac20d72so12822164otv.9; Sat, 11 Dec 2021 09:02:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9pJsVgvIvmnOR5/yZ/QYtmknOuWrq/u7/U+xyMwNvvk=; b=XvDhjG2dAvN9Eh/ZAZ2pOntPYiVf/pyqDU4daA2MkEqpfZE+fPVVsv7UtRU39ysWMW wiDlBATDcEQ1J88a3nGBgrgYBjS4lqeP0pkfuwG51e52BW9Qs3elPlwpdsr2mdXTm247 AtA2RN6TJZtjS6Ka8GvP9mvCysX76G9/WTkr7o1S7fOj0mQGGBtKIWnTKFq3Ouvbr/GP bB/h87mxI/fYtg6I1ayUuWjkHWVK/7R27ybuNDky09KPz6/yrhggMO7CyW+P1KmFQxak ihifKR7Fvxkj1/+yNFiettVCIJr2BHBDsud+9ptosSn68unS3Yi5HsXvbVYNq2132CET R6fA== X-Gm-Message-State: AOAM532bNZ79J1qCVP1OHWxY410sBKP/g29Z/LoxQxAquZEOqYQidBHY b/2qyq+D1X5Rz48Ek3iQGYRWjwStpsr7gX2JSLF6+bRi X-Google-Smtp-Source: ABdhPJyO2AwFQpdp60AWFXTe7s9srovXDb6+iqI21LwZU5DeB9Q+DSf05Q+Guuz8wpiHOayGq/AikeZN2G5HzCkf+7M= X-Received: by 2002:a9d:6d98:: with SMTP id x24mr16014641otp.371.1639242167241; Sat, 11 Dec 2021 09:02:47 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Alan Somers Date: Sat, 11 Dec 2021 10:02:36 -0700 Message-ID: Subject: Re: What to use in place of abstract unix sockets? To: Gleb Popov Cc: "Daniel O'Connor" , Eugene Grosbein , freebsd-hackers Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4JBDbx5p7Gz4Yq8 X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of asomers@gmail.com designates 209.85.210.45 as permitted sender) smtp.mailfrom=asomers@gmail.com X-Spamd-Result: default: False [0.75 / 15.00]; ARC_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; FREEFALL_USER(0.00)[asomers]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; RCVD_TLS_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-0.25)[-0.250]; RWL_MAILSPIKE_GOOD(0.00)[209.85.210.45:from]; NEURAL_SPAM_MEDIUM(1.00)[1.000]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-0.999]; RCVD_IN_DNSWL_NONE(0.00)[209.85.210.45:from]; FORGED_SENDER(0.30)[asomers@freebsd.org,asomers@gmail.com]; SUBJECT_ENDS_QUESTION(1.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[asomers@freebsd.org,asomers@gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-Spam: Yes X-ThisMailContainsUnwantedMimeParts: N On Fri, Dec 10, 2021 at 12:54 AM Gleb Popov wrote: > > On Wed, Dec 8, 2021 at 10:50 AM Eugene Grosbein wrote: > > > 08.12.2021 13:43, Gleb Popov wrote: > > > > > Hello hackers. > > > > > > I'm porting a software that does the following things on Linux: > > > > > > 1. Binds an abstract UDS (the socket name starts with '\0') > > > 2. Launches a "client" process. > > > 3. "Client" uses chroot() to constrain itself in a sort of jail. > > > 4. "Client" connects to the abstract UDS. > > > > > >>From what I can tell, this works because abstract UDS's do not use the > > > filesystem namespace, which is why "client" can connect out of the > > > chroot'ed environment. > > > > > > What can I do to make this software work for FreeBSD? Simply using > > regular > > > UDS instead of abstract ones doesn't work for obvious reasons - the > > > "client" can't find the socket file. > > > > > > Thanks in advance. > > > > If they are parent/child, you could try using socketpair(). > > > > There are actually multiple children. If I understand it right, using > socketpair() would lead to N sockets on the server side for the N connected > clients. Right now there is a single UDS that handles all connections, so > rewriting it with socketpair() would be problematic, I think. > > > > > On Thu, Dec 9, 2021 at 3:08 AM Daniel O'Connor wrote: > > > > > > > > On 8 Dec 2021, at 17:13, Gleb Popov wrote: > > > I'm porting a software that does the following things on Linux: > > > > > > 1. Binds an abstract UDS (the socket name starts with '\0') > > > 2. Launches a "client" process. > > > 3. "Client" uses chroot() to constrain itself in a sort of jail. > > > 4. "Client" connects to the abstract UDS. > > > > > > From what I can tell, this works because abstract UDS's do not use the > > > filesystem namespace, which is why "client" can connect out of the > > > chroot'ed environment. > > > > > > What can I do to make this software work for FreeBSD? Simply using > > regular > > > UDS instead of abstract ones doesn't work for obvious reasons - the > > > "client" can't find the socket file. > > > > If the parent knows where the child will chroot it could create a unix > > domain socket under that directory somewhere. > > > > Same problem as above - there should be a single socket on the server side. Since socketpair() doesn't work in this case, why not just use a UDP socket bound to 127.0.0.1 ?