ownership of NTFS

Technical issues/questions of an intermediate or advanced nature.
rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

ownership of NTFS

Post#1 by rych » 29 Oct 2022, 08:32

I've just realized that all (*) of my NTFS and FAT32 partitions are mounted under "guest" ownership (guest:root). Is it okay to change it to root, and where do I do it? I guess I should specify uid=value at mount as chown command has no effect.

(*) except one NTFS USB plugged in later which is mounted as root:root! So something else is probably going on. NTFS inherently doesn't carry any "guest" or "root" ownership, so it must be Porteus that (arbitrary?) decides the owner when mounting?

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3939
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

ownership of NTFS

Post#2 by ncmprhnsbl » 29 Oct 2022, 14:38

good question. . it'd be somewhere between udisks and our /sbin/udev-fstab-update script, i think.
but as you say, any such ownership pretty meaningless
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
babam
Warlord
Warlord
Posts: 528
Joined: 16 Nov 2016, 10:30
Distribution: Porteus 5.0rc3 Xfce K6.1.1
Location: Rainy city

ownership of NTFS

Post#3 by babam » 29 Oct 2022, 15:16

In my experience if ownership is root:root then "Move to trash" doesn't work.

NTFS3 is great, as is the linux filesystem that supports permissions, ownership and ACLs.
Sorry, my English is bad.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3939
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

ownership of NTFS

Post#4 by ncmprhnsbl » 30 Oct 2022, 11:41

ok, i see there's some inconsistency .. ntfs and vfat mounted at boot (covered by the finit script in initrd.xz) has a uid=1000 flag (i think this was done to accommodate trash usage) .. whereas udev-fstab-update doesn't.. hence the difference for mounts after boot..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

ownership of NTFS

Post#5 by rych » 30 Oct 2022, 13:56

ncmprhnsbl, indeed /sbin/udev-fstab-update applies different options:

Code: Select all

[ $MOPT ] || MOPT="users,noatime,nodiratime,suid,dev,exec,async"
[ $NMOPT ] || NMOPT="noatime,nodiratime,group,nodev,exec,async"
resulting in:

Code: Select all

root@porteus:~# cat /etc/fstab 
# Do not edit this file as fstab is recreated automatically during every boot.
# Please use /etc/rc.d/rc.local or sysvinit scripts if you want to mount/unmount
# drive, filesystem or network share.

# System mounts:
aufs / aufs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs defaults 0 0
devpts /dev/pts devpts rw,mode=0620,gid=5 0 0

# Device partitions:

# Hotplugged devices:
/dev/sda3 /mnt/sda3 ntfs-3g noatime,nodiratime,group,nodev,exec,async,comment=x-gvfs-show 0 0
/dev/sda1 /mnt/sda1 vfat users,noatime,nodiratime,suid,dev,exec,async,comment=x-gvfs-show,umask=0,check=s,utf8 0 0
/dev/sda4 /mnt/sda4 ntfs-3g noatime,nodiratime,group,nodev,exec,async,comment=x-gvfs-show 0 0
/dev/sdb1 /mnt/sdb1 vfat users,noatime,nodiratime,suid,dev,exec,async,comment=x-gvfs-show,umask=0,check=s,utf8 0 0
/dev/sdb3 /mnt/sdb3 ntfs-3g noatime,nodiratime,group,nodev,exec,async,comment=x-gvfs-show 0 0
/dev/sdb2 /mnt/sdb2 ext4 users,noatime,nodiratime,suid,dev,exec,async,comment=x-gvfs-show 0 0
/dev/sdc2 /mnt/sdc2 ext4 users,noatime,nodiratime,suid,dev,exec,async,comment=x-gvfs-show 0 0
/dev/sdc1 /mnt/sdc1 ntfs-3g noatime,nodiratime,group,nodev,exec,async,comment=x-gvfs-show 0 0
partitions sda1, sda3, sda4, oddly sdb1, and sdb3 are mounted under ownership of guest:root.

I don't ever use guest, and yet it appears to be a rather special, privileged account on my system as whole (windows) partitions are owned by it. I wonder why, and what do I change to make mounted file systems owned by root:root (except /home/guest) -- when I log in as root at least?

But there is more.

All that was about mounting at boot. Now, if I hotplug an NTFS USB I get and e.g. /mnt/sdc1 above, it's mounted as root:root, by SpaceFM I guess, so it picked up the correct current user (root)?

Is it possible that mounting command during boot for windows partitions is executed on behalf of the guest user?! And I suspect we need to look into initrd (linuxrc and/or finit) and the fstab above is irrelevant (too late) during boot?

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3939
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

ownership of NTFS

Post#6 by ncmprhnsbl » 31 Oct 2022, 01:10

rych wrote:
30 Oct 2022, 13:56
All that was about mounting at boot. Now, if I hotplug an NTFS USB I get and e.g. /mnt/sdc1 above, it's mounted as root:root, by SpaceFM I guess, so it picked up the correct current user (root)?

Is it possible that mounting command during boot for windows partitions is executed on behalf of the guest user?! And I suspect we need to look into initrd (linuxrc and/or finit) and the fstab above is irrelevant (too late) during boot?
to summarize:
vfat and ntfs mounted at boot are mounted guest:root (defined by finit using uid=1000 (1000=guest)) (needed for guest trash users)
vfat and ntfs mounted after boot are mounted root:root (defined by udev-fstab-update)

probably the solution will be to make the finit uid=1000 conditional, checking for login=root cheatcode and using uid=0 in that case (or leaving it out altogether)
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

ownership of NTFS

Post#7 by rych » 31 Oct 2022, 02:11

ncmprhnsbl wrote:
31 Oct 2022, 01:10
probably the solution will be to make the finit uid=1000 conditional, checking for login=root
Thanks for your attention to this rather academic* issue. I guess initrd doesn't know who's going to login and assumes the most democratic choice: guest. But then, if it really doesn't matter* it could as well mount those under root:root.

(*) One scenario where it could matter, one of my syncing solutions may be considering files with different ownership as different files. I'm tracking down that issue and hope to solve it there without digging into initrd. Hope it never matters who owns what as long as root has all permissions it needs?
Last edited by rych on 31 Oct 2022, 08:07, edited 1 time in total.

User avatar
Ed_P
Contributor
Contributor
Posts: 8369
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

ownership of NTFS

Post#8 by Ed_P » 31 Oct 2022, 04:46

I don't understand the problem of drives mounted as guest when you login in as root. Root has access to all drives. If the drives are mounted as root, a guest login would not be able to access them and most users log in as guest.
Ed

rych
Warlord
Warlord
Posts: 622
Joined: 04 Jan 2014, 04:27
Distribution: Porteus 5.0 x64 OpenBox
Location: NZ
Contact:

ownership of NTFS

Post#9 by rych » 31 Oct 2022, 08:33

Indeed finit inside initrd mounts ntfs and vfat with uid=1000. What are the ways to confirm this a posteriori, I've found one:

Code: Select all

root@porteus:~# pgrep -a ntfs-3g
233 ntfs-3g /dev/nvme0n1p3 /mnt/nvme0n1p3 -o noatime,nodiratime,suid,dev,exec,async,uid=1000,big_writes
256 ntfs-3g /dev/sda3 /mnt/sda3 -o noatime,nodiratime,suid,dev,exec,async,uid=1000,big_writes
Suppose I wanted to modify initrd how would I unpack and pack it back? Are the old instructions in Re: Fixed mount paths for other partitions than root (Post by Gele #27281) still valid?

Also, how would I check for the presence of login=root cheatcode?
Last edited by rych on 01 Nov 2022, 08:12, edited 1 time in total.

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 3939
Joined: 20 Mar 2012, 03:42
Distribution: v5.0-64bit
Location: australia
Contact:

ownership of NTFS

Post#10 by ncmprhnsbl » 01 Nov 2022, 02:21

rych wrote:
31 Oct 2022, 08:33
still valid?
looks okay
rych wrote:
31 Oct 2022, 08:33
Also, how would I check for the presence of login=root cheatcode?
there's the function in finit (although it's defined at the end, so might not work in finit? i forget how bash functions are parsed)

Code: Select all

# Check for a boot param
chk_bootcfg(){ grep "^$1" /union/etc/bootcmd.cfg; }
so
chk_bootcfg login=root
or just use

Code: Select all

grep "^login=root" /union/etc/bootcmd.cfg
or maybe even (in case this mounting occurs before /union/etc/bootcmd.cfg gets made)

Code: Select all

grep "^login=root" /proc/cmdline
for your own purposes though, you could just remove the uid=1000 bits, without the need for any conditional.
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

Post Reply