Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
util-linux.25288
util-linux-mesg-use-only-stat.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-mesg-use-only-stat.patch of Package util-linux.25288
From c0246ce059503bbc078122a50d564ca36a66f348 Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@redhat.com> Date: Mon, 12 Apr 2021 09:39:59 +0200 Subject: [PATCH] mesg: use only stat() to get the current terminal status open()+stat() does not work for example after su(1) (from root to non-root). It seems better to use only stat() to get the current terminal status. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1906157 Signed-off-by: Karel Zak <kzak@redhat.com> --- term-utils/mesg.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) Index: util-linux-2.31.1/term-utils/mesg.c =================================================================== --- util-linux-2.31.1.orig/term-utils/mesg.c +++ util-linux-2.31.1/term-utils/mesg.c @@ -123,13 +123,9 @@ int main(int argc, char *argv[]) if ((tty = ttyname(STDERR_FILENO)) == NULL) err(MESG_EXIT_FAILURE, _("ttyname failed")); - if ((fd = open(tty, O_RDONLY)) < 0) - err(MESG_EXIT_FAILURE, _("cannot open %s"), tty); - if (fstat(fd, &sb)) - err(MESG_EXIT_FAILURE, _("stat of %s failed"), tty); - if (!*argv) { - close(fd); + if (stat(tty, &sb)) + err(MESG_EXIT_FAILURE, _("stat of %s failed"), tty); if (sb.st_mode & (S_IWGRP | S_IWOTH)) { puts(_("is y")); return IS_ALLOWED; @@ -138,6 +134,11 @@ int main(int argc, char *argv[]) return IS_NOT_ALLOWED; } + if ((fd = open(tty, O_RDONLY)) < 0) + err(MESG_EXIT_FAILURE, _("cannot open %s"), tty); + if (fstat(fd, &sb)) + err(MESG_EXIT_FAILURE, _("stat of %s failed"), tty); + switch (rpmatch(argv[0])) { case RPMATCH_YES: #ifdef USE_TTY_GROUP
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor