• Re: [gentoo-user] Root can't write to files owned by others?

    From Jack@21:1/5 to Dr Rainer Woitok on Wed Mar 9 19:40:01 2022
    On 2022.03.09 13:28, Dr Rainer Woitok wrote:
    Greetings,

    until recently my system behaves sort of strangely:

    $ touch /tmp/file
    $ ls -l /tmp/file
    -rw------- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    Password:
    tee: /tmp/file: Permission denied
    x
    $ chmod a+w /tmp/file
    $ ls -l /tmp/file
    -rw--w--w- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    tee: /tmp/file: Permission denied
    x
    $

    Since when can't root write to files it doesn't own? And not even,
    if
    the file has write permission for everybody?

    This worked as long as I can think of. My last routine upgrade
    install-
    ed new kernel package "sys-kernel/gentoo-sources-5.15.26", so I
    built
    the new kernel and booted from it. May this be the reason?

    When I'll have time to reboot, I'll test the above commands on my
    old
    kernel, 5.15.19. But perhaps there's another reason?

    Slightly puzzled
    Rainer
    Just a gues, but try something like 'sudo -c "echo x | tee /tmp/file"'
    or just su first and then do the echo and tee. I think perhaps the permission error is not for root writing to /tmp/file but for the echo
    x trying to write to a tee owned by root.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dr Rainer Woitok@21:1/5 to All on Wed Mar 9 19:30:01 2022
    Greetings,

    until recently my system behaves sort of strangely:

    $ touch /tmp/file
    $ ls -l /tmp/file
    -rw------- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    Password:
    tee: /tmp/file: Permission denied
    x
    $ chmod a+w /tmp/file
    $ ls -l /tmp/file
    -rw--w--w- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    tee: /tmp/file: Permission denied
    x
    $

    Since when can't root write to files it doesn't own? And not even, if
    the file has write permission for everybody?

    This worked as long as I can think of. My last routine upgrade install-
    ed new kernel package "sys-kernel/gentoo-sources-5.15.26", so I built
    the new kernel and booted from it. May this be the reason?

    When I'll have time to reboot, I'll test the above commands on my old kernel, 5.15.19. But perhaps there's another reason?

    Slightly puzzled
    Rainer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Peter =?ISO-8859-1?Q?B=F6hm?=@21:1/5 to All on Wed Mar 9 19:50:01 2022
    Rainer,

    using sudo does not makes you a root user. To become a root user you have to switch with "su -" (and login with root password).

    Sudo has its own configuration file. If you can do something with sudo on other
    systems means there is a different configuration for sudo.

    Check "man sudo"

    Cheers,
    Peter


    Am Mittwoch, 9. März 2022, 19:28:49 CET schrieb Dr Rainer Woitok:
    Greetings,

    until recently my system behaves sort of strangely:

    $ touch /tmp/file
    $ ls -l /tmp/file
    -rw------- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    Password:
    tee: /tmp/file: Permission denied
    x
    $ chmod a+w /tmp/file
    $ ls -l /tmp/file
    -rw--w--w- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file
    $ echo x | sudo tee /tmp/file
    tee: /tmp/file: Permission denied
    x
    $

    Since when can't root write to files it doesn't own? And not even, if
    the file has write permission for everybody?

    This worked as long as I can think of. My last routine upgrade install-
    ed new kernel package "sys-kernel/gentoo-sources-5.15.26", so I built
    the new kernel and booted from it. May this be the reason?

    When I'll have time to reboot, I'll test the above commands on my old kernel, 5.15.19. But perhaps there's another reason?

    Slightly puzzled
    Rainer

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)