WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: why does boot process change /opt ownership to root?  (Read 125 times)

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
why does boot process change /opt ownership to root?
« on: September 11, 2020, 05:51:35 AM »
I use the  opt=sda3  and  user=bruno  boot codes. Boot process consistently changes ownership of the /mnt/sda3/opt directory to root for some reason:

Code: [Select]
$ sudo chown bruno /mnt/sda3/opt
$ ls -ld /mnt/sda3/opt
drwxrwsr-x    8 bruno    staff         4096 Mar 30 02:45 /mnt/sda3/opt/
$ sudo reboot
...wait for system to reboot...
$ ls -ld /mnt/sda3/opt
drwxrwsr-x    8 root     staff         4096 Mar 30 02:45 /mnt/sda3/opt/

I recursively grep'ed through /etc for both "chown" and "/opt" and did not find any clues as to how or why this happens. Any ideas?

Offline jazzbiker

  • Sr. Member
  • ****
  • Posts: 317
Re: why does boot process change /opt ownership to root?
« Reply #1 on: September 11, 2020, 06:03:29 AM »
Hi, GNUser!

I think, that /opt is the native part of rootfs.gz with root:staff owner, and it is filled during boot process without changing the ownership. How about this explanation?

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
Re: why does boot process change /opt ownership to root?
« Reply #2 on: September 11, 2020, 06:38:43 AM »
Hi, jazzbiker! As always, thanks for your input.

What you're saying would explain root ownership of /opt but not the changed ownership (from bruno to root) of /mnt/sda3/opt.

To make my observation more concrete: If I shutdown TCL, boot into a different OS on same harddisk, and check the ownership of /mnt/sda3/opt, I still see that the ownership has been changed to root:staff.

Offline jazzbiker

  • Sr. Member
  • ****
  • Posts: 317
Re: why does boot process change /opt ownership to root?
« Reply #3 on: September 11, 2020, 07:03:20 AM »
Hi, GNUser!

Its amazing, I can say nothing yet on such behaviour :-(
Besides I've found funny trick which allows to change directory ownership during "tared" restore using -T "some.list". For example, if Your "some.list" conatins
Code: [Select]
opt
then ownership will be unchanged, but in case Your "some.list" contains
Code: [Select]
opt/../opt
ownership is updated.

I checked this trick only in the sandbox, not for full the shutdown-boot TC cycle.
According to Your refinement, sad but if You need to change ownership for some other OS use, this will not help.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
Re: why does boot process change /opt ownership to root?
« Reply #4 on: September 11, 2020, 07:15:58 AM »
Hi, jazzbiker. That's some funky  tar  behavior your discovered. Thanks for sharing :)

I found a section in  /etc/init.d/tc-config  that handles  OPT_SETUP  via the  MYOPT  variable. Nothing in that section seems to account for the change in ownership.

This is not a big deal, by the way. I'm just trying to understand it because I don't like unexplained behaviors.

Offline jazzbiker

  • Sr. Member
  • ****
  • Posts: 317
Re: why does boot process change /opt ownership to root?
« Reply #5 on: September 11, 2020, 07:21:40 AM »
Of course, its normal to understand wats going on inside Your box, I totally agree with Your intentions, thanks for asking not-obvious questions, helping to clear some hidden ways.
But as I understand Your description, the named ownership change took place not during boot, but during shutdown. Don't You quess so?

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
Re: why does boot process change /opt ownership to root?
« Reply #6 on: September 11, 2020, 07:24:06 AM »
not during boot, but during shutdown. Don't You quess so?
Huh. I was assuming during boot but I guess it could be during shutdown. I'll do some experiments to prove which one. Stay tuned.

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
Re: why does boot process change /opt ownership to root?
« Reply #7 on: September 11, 2020, 07:29:22 AM »
Boot process is definitely the culprit. TCL shutdown process does not change ownership of /mnt/sda3/opt:

Code: [Select]
TCL$ sudo chown bruno /mnt/sda3/opt
TCL$ ls -ld /mnt/sda3/opt
drwxrwsr-x    8 bruno    staff         4096 Mar 30 02:45 /mnt/sda3/opt/
TCL$ sudo poweroff
...boot into a different OS, mount the sda3 partition, cd to the mounted sda3 partition...
Devuan$ ls -ld opt
drwxrwsr-x    8 bruno     staff         4096 Mar 30 02:45 opt

Offline jazzbiker

  • Sr. Member
  • ****
  • Posts: 317
Re: why does boot process change /opt ownership to root?
« Reply #8 on: September 11, 2020, 07:37:52 AM »
Hmm... then the trick i'm proposing may help. If You want i will check it by myself, in order not to make the troubles for You. But I don't use any persistance, so I will do this  a little bit later after some preparations, Ok?

Offline GNUser

  • Hero Member
  • *****
  • Posts: 628
Re: why does boot process change /opt ownership to root?
« Reply #9 on: September 11, 2020, 07:45:24 AM »
Thanks, jazzbiker, but a simpler fix would be to add "sudo chown bruno /mnt/sda3/opt" to my startup jobs in ~/.X/

I'm not necessarily trying to fix the issue, just understand what's going on. If I do fix the issue, I'd like to fix it by changing the part of the boot process that's responsible for it.

Offline jazzbiker

  • Sr. Member
  • ****
  • Posts: 317
Re: why does boot process change /opt ownership to root?
« Reply #10 on: September 11, 2020, 07:52:03 AM »
Ok, Your way is more straightforward thus the better one, agree. If talking about understanding, I hope we'd got it :-) Thanks for Your questions, digging and contributing to finest OS ever ! :-)