Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #162631

Re: Prevent shutdown with systemctl

From David Wright <deblis@lionunicorn.co.uk>
Newsgroups linux.debian.user
Subject Re: Prevent shutdown with systemctl
Date 2016-01-05 06:10 +0100
Message-ID <qNs2C-5ze-9@gated-at.bofh.it> (permalink)
References (1 earlier) <qNgXw-6p8-19@gated-at.bofh.it> <qNhqx-6E0-1@gated-at.bofh.it> <qNjVp-8lm-23@gated-at.bofh.it> <qNkHM-sc-9@gated-at.bofh.it> <qNlaP-Er-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon 04 Jan 2016 at 16:43:05 (-0500), Gary Dale wrote:
> On 04/01/16 03:39 PM, tomas@tuxteam.de wrote:
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >On Mon, Jan 04, 2016 at 03:25:02PM -0500, Gary Dale wrote:
> >>On 04/01/16 12:14 PM, tomas@tuxteam.de wrote:
> >[...]
> >
> >>>Dunno about systemctl, but FWIW you can't change the permissions of
> >>>a symlink. It's always "all on".
> >>>
> >>>
> >>Interesting. Why do they behave that way? Hard links don't (but
> >>replacing the symlink with a hardlink would fail if /bin & /sbin
> >>were on different devices. Also, I gather that systemctl looks at
> >>how it is called to determine the action it needs to take - would
> >>that create a problem if called from a hard link instead of a
> >>symlink?).
> >Perhaps I was a bit cavalier with my "all on": applications *doing* something
> >useful with a symlink reference it (except things like "rm", of course).
> >
> >Thus, the permissions of the referenced-to file apply. Otherwise --
> >imagine: I do an ln -s /bin/bash $HOME, chmod u+w $HOME/bas
> >(since I own the link) and now have write access to the system shell?!
> >
> >Hard links are a completely different kind of animal: they are
> >alternative directory entries for the same blob of data. Consequently,
> >there is no "primary" (as there is in symlinks). There are no
> >dangling hardlinks (unless your file system is corrupted).
> >As you can well imagine, some restrictions apply in the creation
> >of hardlinks:
> >
> >   tomas@rasputin:~$ sudo useradd -m test
> >   [sudo] password for tomas:
> >   tomas@rasputin:~$ ls -al /home/test
> >   total 20
> >   drwxr-xr-x 2 test test 4096 Jan  4 21:50 .
> >   drwxr-xr-x 9 root root 4096 Jan  4 21:50 ..
> >   -rw-r--r-- 1 test test  220 Apr 10  2010 .bash_logout
> >   -rw-r--r-- 1 test test 3392 Jul 13  2012 .bashrc
> >   -rw-r--r-- 1 test test  675 Apr 10  2010 .profile
> >   tomas@rasputin:~$ ln /home/test/.profile test-profile
> >   ln: failed to create hard link `test-profile' => `/home/test/.profile': Operation not permitted
> >
> >Regards
> >- -- tomás
> Actually I don't see it that way at all. The symlink example is no
> different from the hardlink case in that I can create a hardlink
> that has different permissions than the original file.

It would be interesting to see some support of this view, like the
output of   ls -li   showing the same inode numbers and the
different permissions. BTW the concept of "original file" is rendered
meaningless with hard links; all the links have the same status.

> Indeed I can
> execute systemctl as a normal user by creating a hardlink to it.

As pointed out already, anyone can execute systemctl if you haven't
mangled its proper permissions. Again, could you please show us the
hard links and their locations.

> If
> that is a problem with symlinks, shouldn't it also be with
> hardlinks?

It might be worthwhile taking a look at   man 2 link,   man 2 symlink
and   man 7 symlink.

Cheers,
David.

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 17:00 +0100
  Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-04 18:20 +0100
    Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 20:10 +0100
      Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 21:00 +0100
        Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-04 21:20 +0100
      Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-04 21:50 +0100
        Re: Prevent shutdown with systemctl Floris <jkfloris@dds.nl> - 2016-01-04 23:50 +0100
          Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 00:50 +0100
            Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-05 01:30 +0100
              Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 01:40 +0100
  Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 18:20 +0100
    Re: Prevent shutdown with systemctl <tomas@tuxteam.de> - 2016-01-04 18:50 +0100
      Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 21:20 +0100
        Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 21:40 +0100
          Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 22:10 +0100
            Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 22:50 +0100
              Re: Prevent shutdown with systemctl Michael Biebl <biebl@debian.org> - 2016-01-05 01:20 +0100
                Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-05 18:20 +0100
      Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 21:30 +0100
        Re: Prevent shutdown with systemctl Stuart Longland <stuartl@longlandclan.id.au> - 2016-01-04 22:00 +0100
          Re: Prevent shutdown with systemctl David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 05:50 +0100
        Re: Prevent shutdown with systemctl <tomas@tuxteam.de> - 2016-01-04 22:20 +0100
          Re: Prevent shutdown with systemctl Gary Dale <garydale@torfree.net> - 2016-01-04 22:50 +0100
            Re: Prevent shutdown with systemctl David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 06:10 +0100
            Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] <tomas@tuxteam.de> - 2016-01-05 09:40 +0100
              Re: Symlinks vs. hardlinks "Thomas Schmitt" <scdbackup@gmx.net> - 2016-01-05 11:10 +0100
                Re: Symlinks vs. hardlinks <tomas@tuxteam.de> - 2016-01-05 11:40 +0100
              Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] <tomas@tuxteam.de> - 2016-01-05 16:30 +0100
              Re: Symlinks vs. hardlinks [was: Prevent shutdown with systemctl] David Wright <deblis@lionunicorn.co.uk> - 2016-01-05 16:30 +0100
  Re: Prevent shutdown with systemctl Jude DaShiell <jdashiel@panix.com> - 2016-01-04 19:20 +0100
  Re: Prevent shutdown with systemctl Brian <ad44@cityscape.co.uk> - 2016-01-04 19:30 +0100
    Re: Prevent shutdown with systemctl jdd <jdd@dodin.org> - 2016-01-04 20:10 +0100
      Re: Prevent shutdown with systemctl jdd <jdd@dodin.org> - 2016-01-04 20:30 +0100
      Re: Prevent shutdown with systemctl Chris Bannister <cbannister@slingshot.co.nz> - 2016-01-05 11:10 +0100

csiph-web