From: J William Piggott <elseifthen@gmx.com>
To: Karel Zak <kzak@redhat.com>
Cc: Marian Vomir <marian.vomir@ni.com>, util-linux@vger.kernel.org
Subject: Re: [PATCH 1/2] Revert "hwclock: don't allow non-root access"
Date: Thu, 8 Dec 2016 21:09:15 -0500 [thread overview]
Message-ID: <82bcda5b-fe4e-553a-fa1f-32c37f3fba54@gmx.com> (raw)
In-Reply-To: <20161207112541.2g3trc26tcvcghio@ws.net.home>
On 12/07/2016 06:25 AM, Karel Zak wrote:
> On Tue, Dec 06, 2016 at 06:40:32PM -0500, J William Piggott wrote:
>>
>>
>> On 12/06/2016 01:06 PM, Marian Vomir wrote:
>>> This reverts commit 687cc5d58942b24a9f4013c68876d8cbea907ab1.
>>>
>>> There are cases when an unprivileged user wants to set the hardware clock.
>>
>> This has never been allowed in over two decades of hwclock. I cannot
>> think of a legitimate reason to allow setting the Hardware Clock by a
>> normal user.
>
> Yes. It seems Marian has missed the goal of the commit
> 687cc5d58942b24a9f4013c68876d8cbea907ab1. It's not about permissions
> detection.
>
> We don't want to support use-case where hwclock(8) has extra
> permissions (setuid or CAP_<something>) to set system time. The binary
> is not designed for this purpose and it does not make sense to support
> it -- less utils with extra permissions is better.
>
>> Having said that, while I agree with Karel's desire to remove all
>> mention of running hwclock with setuid, IMO the code should not have
>> been removed. Despite the comment directly above it, that code has
>> nothing to do with hwclock being run with setuid.
>
> Maybe my patch seems too strict, but change docs is not enough, the
> code matters. We want to be sure nobody uses hwclock as setuid,
> especially if man page and code comments promised this non-sense.
I agree that setuid should be removed from the man-page and source
comments. I do not think the code was a problem; removing it does not
prevent running it with setuid. It only prevents users from access to
the benign read only functions of hwclock which they have historically
had.
>
>> I would argue that there are some hwclock options intended for normal
>> users. A normal users should at least be able to display the Hardware
>> Clock time.
>
> We can change it to support --show for non-root users, but the
> question is if such change will have any practical effect, because for
> example on Fedora we have:
>
> $ ll /dev/rtc0
> crw------- 1 root root 251, 0 Nov 28 10:46 /dev/rtc0
>
> so
>
> $ hwclock --debug --show
> hwclock from util-linux 2.29.44-a99c0
> hwclock: cannot open /dev/rtc: Permission denied
> No usable clock interface found.
> hwclock: Cannot access the Hardware Clock via any known method.
>
$ ls -l /dev/rtc0
crw-r--r-- 1 root root 254, 0 2016-12-08 09:50:26 /dev/rtc0
$ /sbin/hwclock
Thu 08 Dec 2016 08:40:08 PM EST .123162 seconds
Perhaps Fedora sets perms that way because it thinks hwclock is
irrelevant for systemd platforms.
> with the untested patch below. IMHO it's waste of time to try to be
> smart in this area... ;-)
>
> Karel
>
>
>
> diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
> index 21caeb2..ede6cfa 100644
> --- a/sys-utils/hwclock.c
> +++ b/sys-utils/hwclock.c
> @@ -1859,11 +1859,6 @@ int main(int argc, char **argv)
> argc -= optind;
> argv += optind;
>
> - if (getuid() != 0) {
> - warnx(_("Sorry, only the superuser can use the Hardware Clock."));
> - hwclock_exit(EX_NOPERM);
> - }
> -
> #ifdef HAVE_LIBAUDIT
> if (testing != TRUE) {
> if (adjust == TRUE || hctosys == TRUE || systohc == TRUE ||
> @@ -1906,6 +1901,11 @@ int main(int argc, char **argv)
> show = 1; /* default to show */
>
>
> + if (!show && getuid() != 0) {
> + warnx(_("Sorry, only --show is allowed for non-root users."));
> + hwclock_exit(EX_NOPERM);
> + }
> +
> #ifdef __linux__
> if (getepoch || setepoch) {
> manipulate_epoch(getepoch, setepoch, epoch_option, testing);
>
> --
> To unsubscribe from this list: send the line "unsubscribe util-linux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2016-12-09 2:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 18:06 [PATCH 1/2] Revert "hwclock: don't allow non-root access" Marian Vomir
2016-12-06 18:06 ` [PATCH 2/2] sys-utils/hwclock: make hwclock check for CAP_SYS_TIME capability Marian Vomir
2016-12-06 23:40 ` [PATCH 1/2] Revert "hwclock: don't allow non-root access" J William Piggott
2016-12-07 11:25 ` Karel Zak
2016-12-08 16:03 ` marian.vomir
2016-12-09 2:09 ` J William Piggott
2016-12-09 2:09 ` J William Piggott [this message]
2016-12-09 8:52 ` Karel Zak
2016-12-09 8:54 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=82bcda5b-fe4e-553a-fa1f-32c37f3fba54@gmx.com \
--to=elseifthen@gmx.com \
--cc=kzak@redhat.com \
--cc=marian.vomir@ni.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox