From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 91EC13954411 for ; Thu, 29 Apr 2021 18:44:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 91EC13954411 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-545-hEm1fKEiOcmvts_Nz0dAUQ-1; Thu, 29 Apr 2021 14:44:14 -0400 X-MC-Unique: hEm1fKEiOcmvts_Nz0dAUQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C9B1710066EA for ; Thu, 29 Apr 2021 18:44:13 +0000 (UTC) Received: from redhat.com (ovpn-116-150.phx2.redhat.com [10.3.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 984515C1A3 for ; Thu, 29 Apr 2021 18:44:13 +0000 (UTC) Received: from fche by redhat.com with local (Exim 4.94) (envelope-from ) id 1lcBe0-0002Hw-Dy for elfutils-devel@sourceware.org; Thu, 29 Apr 2021 14:44:12 -0400 Date: Thu, 29 Apr 2021 14:44:12 -0400 From: "Frank Ch. Eigler" To: elfutils-devel@sourceware.org Subject: PATCH: PR27784 debuginfod: notify interactive clients one time about usage Message-ID: <20210429184412.GC6131@redhat.com> MIME-Version: 1.0 User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2021 18:44:19 -0000 Hi - Another request from fedora fesco. (I don't have anything else on the queue for the next elfutils release.) commit be5ebebb1f12134b673c5b8cbede62390d077b0d Author: Frank Ch. Eigler Date: Thu Apr 29 14:34:06 2021 -0400 PR27784 debuginfod: notify interactive clients one time about usage Because debuginfod-client functionality makes a user dependent on the correct operation of remote debuginfod server, it was suggested that new users be notified of this. This patch adds a one-time notification to stderr if it isatty(), commemorated by a new cache notify_p file. (It cannot easily be tested because our test scripts run without pty/tty enclosure.) Signed-off-by: Frank Ch. Eigler diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog index 20744497e383..800709416c61 100644 --- a/debuginfod/ChangeLog +++ b/debuginfod/ChangeLog @@ -1,3 +1,9 @@ +2021-04-29 Frank Ch. Eigler + + PR27784 + * debuginfod-client.c (debuginfod_query_server): Notify interactive + users, one time, about impending debuginfod-client usage. + 2021-04-29 Frank Ch. Eigler PR27783 diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c index e65aac8b4c1c..d3fbf7caae6d 100644 --- a/debuginfod/debuginfod-client.c +++ b/debuginfod/debuginfod-client.c @@ -141,6 +141,10 @@ static const time_t cache_clean_default_interval_s = 86400; /* 1 day */ static const char *cache_max_unused_age_filename = "max_unused_age_s"; static const time_t cache_default_max_unused_age_s = 604800; /* 1 week */ +/* The cache_notified_p_filename file within the cache indicates the user has + received a one-time notification of debuginfod client operation on a TTY. */ +static const char *cache_notified_p_filename = "notified_p"; + /* Location of the cache of files downloaded from debuginfods. The default parent directory is $HOME, or '/' if $HOME doesn't exist. */ static const char *cache_default_name = ".debuginfod_client_cache"; @@ -503,6 +507,7 @@ debuginfod_query_server (debuginfod_client *c, char *urls_envvar; char *cache_path = NULL; char *maxage_path = NULL; + char *notified_p_path = NULL; char *interval_path = NULL; char *target_cache_dir = NULL; char *target_cache_path = NULL; @@ -678,7 +683,28 @@ debuginfod_query_server (debuginfod_client *c, /* XXX combine these */ xalloc_str (interval_path, "%s/%s", cache_path, cache_clean_interval_filename); xalloc_str (maxage_path, "%s/%s", cache_path, cache_max_unused_age_filename); + xalloc_str (notified_p_path, "%s/%s", cache_path, cache_notified_p_filename); + + + /* If on a TTY, notify the user if this is the first time + debuginfod-client is activated. */ + if (isatty (STDERR_FILENO) && + access (notified_p_path, R_OK)) + { + int fd = open (notified_p_path, O_CREAT | O_RDWR, 0400); + if (fd >= 0) + close (fd); + if (vfd >= 0) + dprintf (vfd, "recorded first notification %s\n", notified_p_path); + + fprintf (stderr, + "\nNOTICE: This system is configured to auto-download debuginfo from:\n%s\n\n", + urls_envvar); + fflush (stderr); + sleep (3); + } + if (vfd >= 0) dprintf (vfd, "checking cache dir %s\n", cache_path); @@ -1112,6 +1138,7 @@ debuginfod_query_server (debuginfod_client *c, } free (cache_path); + free (notified_p_path); free (maxage_path); free (interval_path); free (target_cache_dir); diff --git a/tests/ChangeLog b/tests/ChangeLog index bc2016f40203..1f1b2dd8695b 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2021-04-29 Frank Ch. Eigler + + PR27784 + * run-debuginfod-find.sh: Don't test tty first-use notification. + 2021-04-29 Frank Ch. Eigler PR27783 diff --git a/tests/run-debuginfod-find.sh b/tests/run-debuginfod-find.sh index 9a217121b7e2..cc364c861ca4 100755 --- a/tests/run-debuginfod-find.sh +++ b/tests/run-debuginfod-find.sh @@ -384,6 +384,12 @@ wait_ready $PORT1 'groomed_total{decision="stale"}' 4 rm -rf $DEBUGINFOD_CACHE_PATH # clean it from previous tests +# check for first-use notice; don't bother run this one under valgrind, to collect stderr +# ... but need a pty/tty to trigger the message, so just comment this out for now +# ${abs_top_builddir}/debuginfod/debuginfod-find executable 0000111122223333 2>errfile && false || true +# tempfiles errfile +# grep NOTICE errfile + # this is one of the buildids from the groom-deleted rpms testrun ${abs_top_builddir}/debuginfod/debuginfod-find executable $RPM_BUILDID && false || true # but this one was not deleted so should be still around