From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id CB9775A004E for ; Wed, 19 Jun 2024 10:35:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718786128; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1xqyo459+YloAhPvQzxSwDGmUCfs0NypFAL1aZXsG0=; b=PVajj9HK8nvotHZSsExYLeYHnxkhFvhjxA3UGDir3wFDqsfrAh05RcTDG05F2nsZ8/+vBS 46n5t/ReuEGmzJixEJjTIwW0gor/XeTxsgIniqkQGcSeiOEuJbaI2aeUmzKiLKwDUmLuc/ YXsSwv6GoEnTeuRMAzaRJoJaCTUqh8I= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-594-mXWvQveBMru43FhDSPiWJA-1; Wed, 19 Jun 2024 04:35:27 -0400 X-MC-Unique: mXWvQveBMru43FhDSPiWJA-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-62f4a831dd8so116495737b3.3 for ; Wed, 19 Jun 2024 01:35:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718786126; x=1719390926; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=R1xqyo459+YloAhPvQzxSwDGmUCfs0NypFAL1aZXsG0=; b=W68Ot6yodOokXFSUbQkiBiDZOS8Kqxzqq174464RmWixV1SOHLr2BZa4TgNDGnR4Wf h7uR+9wa86AGatOy9z1Aoyqf7gGH9JecJvY9Z2McyIshGMZOeHMKMAS+Rzp22SK9DKqP ff/JYTVqgoFtp7j5m5XSyHlv8VVfF5cKpwtw7jjkgjCFL5OFH5az0XtxTt/99D5KEZNd q/ApLaTjm8BDO5lvHyfnF12AoQynjBlbF3A5XiCT3uexLEJrSNmiE9T5xdXIIsyDKrUP SJXQP49OVJ/BR3ZPIV3AmcKO3/kO9jVsyZtAHKhEJ0jjD9hlTyscuMKAoEfbMEG+rPug NfKQ== X-Gm-Message-State: AOJu0YzG+azrBpQnbheCBNaoik4LrzP5gAzYN0EfBfhr7UW/8HSaFNGO 7tEUm/0DJxDBKuFU3p3LgjEvAbuDanWmJhUb95e2ilW5XRbfDUtBrXlUlRUSjxVs2p8KTOae/P+ +uUlvmmLC0QomWhJtCvWSI0BDyympTUjkiJdnkK/BRrVuXnSY4A== X-Received: by 2002:a81:4324:0:b0:627:e963:2bcf with SMTP id 00721157ae682-63a903a4478mr18553527b3.51.1718786125206; Wed, 19 Jun 2024 01:35:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGQl5ticra+hetOPaFRbcTdlaSO+VIMpFYQYASfl5oNw2UbVClhBLAH6Q7L7F7HQMtsVsmrhQ== X-Received: by 2002:a81:4324:0:b0:627:e963:2bcf with SMTP id 00721157ae682-63a903a4478mr18553407b3.51.1718786124572; Wed, 19 Jun 2024 01:35:24 -0700 (PDT) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b5081215c1sm2850406d6.138.2024.06.19.01.35.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jun 2024 01:35:23 -0700 (PDT) Date: Wed, 19 Jun 2024 10:34:48 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v2 1/6] conf, passt: Don't try to log to stderr after we close it Message-ID: <20240619103433.57405b48@elisabeth> In-Reply-To: References: <20240618071427.1544869-1-sbrivio@redhat.com> <20240618071427.1544869-2-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: DX34ELL7WYX5JJVLXTSXQH4JGQXFKZAP X-Message-ID-Hash: DX34ELL7WYX5JJVLXTSXQH4JGQXFKZAP X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Yalan Zhang X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 19 Jun 2024 12:14:53 +1000 David Gibson wrote: > On Tue, Jun 18, 2024 at 09:14:22AM +0200, Stefano Brivio wrote: > > If we don't run in foreground, we close standard error as we > > daemonise, so it makes no sense to check if the controlling terminal > > is an interactive terminal or if --force-stderr was given, to decide > > if we want to log to standard error. > > > > Make --force-stderr depend on --foreground. > > > > Signed-off-by: Stefano Brivio > > --- > > conf.c | 3 +++ > > passt.c | 2 +- > > 2 files changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/conf.c b/conf.c > > index 94b3ed6..dbdbb62 100644 > > --- a/conf.c > > +++ b/conf.c > > @@ -1693,6 +1693,9 @@ void conf(struct ctx *c, int argc, char **argv) > > > > conf_ugid(runas, &uid, &gid); > > > > + if (!c->foreground && c->force_stderr) > > + die("Can't log to standard error if not running in foreground"); > > + > > if (logfile) { > > logfile_init(c->mode == MODE_PASTA ? "pasta" : "passt", > > logfile, logsize); > > diff --git a/passt.c b/passt.c > > index a5e2c5a..aa9648a 100644 > > --- a/passt.c > > +++ b/passt.c > > @@ -302,7 +302,7 @@ int main(int argc, char **argv) > > if (isolate_prefork(&c)) > > die("Failed to sandbox process, exiting"); > > > > - if (!c.force_stderr && !isatty(fileno(stderr))) > > + if (!c.foreground || (!c.force_stderr && !isatty(fileno(stderr)))) > > __openlog(log_name, 0, LOG_DAEMON); > > Hm.. kind of preexisting, but shouldn't we still skip the __openlog() > if we have a logfile? Ah, true. I would add this as a separate patch. > Or make __openlog() open either the syslog or > the logfile as appropriate (but in that case we should rename it not > to look like openlog(3)). I would rather keep __openlog() as openlog() implementation, because the semantics are well specified like this. We just need another function, or even a direct setting, for LOG_PERROR (or get rid of that flag, internally?). -- Stefano