This is a multi-part message in MIME format.
Am Samstag, 3. Mai 2025, 12:22:45 CEST schrieb Haines Brown:
I want to enable a user to copy files to a USB key mounted on a directory under /media.
I can change the ownership of that directory to that of the user, but
when I mount the the key on it the ownsrhip reverts to root. As the
result a user cannot copy files to the key. I would enable the user to
copy files to the key and preserve their ownership.
This must be a common problem, but I have not found a solution on
line or in man mount.
We need some informations of the environment:
1. Which filesystem do you want to mount? FAT, FAT32, VFAT and exfat should work without any
changes. Do they?
2. Do you want to mount different devices or always the same?
3. Do you want to allow it only one special user, several or all users?
I had a similar problem in the future. But I only need to allow it ONE user and always for the
same device. The solution, was to use ACL`s, which overwrite filesystem settings.
This is what I did:
--------------------
Create a new folder with the username of your user, let us say his username is "miller" wu´ith
group "miler"
If exists, delete /media/miller
rmdir /media/miller
Then create a new one:
mkdir /media/miller
---------------------
Now check ACL settings, should look like these:
getfacl /media/miller/
getfacl: Removing leading '/' from absolute path names
# file: media/miller/
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
--------------------
Now we have to set the correct rights for the user "miller"
user rights:
setfacl -m u:miller:rwx /media/miller
--------------------
group rights:
setfacl -m g:miller:--- /media/miller
--------------------
Rest of world:
setfacl -m o::--- /media/miller
--------------------
At last set mask:
setfacl -k --mask /media/miller
--------------------
If everything is correct, it should look like this:
getfacl /media/miller/
getfacl: Removing leading '/' from absolute path names
# file: media/miller/
# owner: root
# group: root
user::rwx
user:miller:rwx
group::---
mask::rwx
other::---
-------------------
I hope this helps a litte bit.
If I described something wrong, please feel free, to correct it! I made this from my
remembering and my environment is German.
Best
Hans
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Am Samstag, 3. Mai 2025, 12:22:45 CEST schrieb Haines Brown:</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I want to enable a user to copy files to a USB key mounted on a directory</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> under /media.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> I can change the ownership of that directory to that of the user, but</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> when I mount the the key on it the ownsrhip reverts to root. As the</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> result a user cannot copy files to the key. I would enable the user to</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> copy files to the key and preserve their ownership.</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> </p> <p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> This must be a common problem, but I have not found a solution on</p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">> line or in man mount.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">We need some informations of the environment:</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">1. Which filesystem do you want to mount? FAT, FAT32, VFAT and exfat should work without any changes. Do they?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">2. Do you want to mount different devices or always the same?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">3. Do you want to allow it only one special user, several or all users?</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I had a similar problem in the future. But I only need to allow it ONE user and always for the same device. The solution, was to use ACL`s, which overwrite filesystem settings.</
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">This is what I did:</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"><span style="font-family:Noto Sans;">-------------------- </span></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">Create a new folder with the username of your user, let us say his username is "miller" wu´ith group &
quot;miler"</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">If exists, delete /media/miller</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">rmdir /media/miller</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">Then create a new one:</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">mkdir /media/miller</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">---------------------</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">Now check ACL settings, should look like these:</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">getfacl /media/miller/ </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">getfacl: </span></span><span style="font-family:monospace;"><span style="color:#000000;"><span style="background-
color:#ffffff;">Removing leading '/' from absolute path names</span></span></span><span style="color:#31363b;"><span style="background-color:#fafafa;"><span style="font-family:Noto Sans;"> </span></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"># file: media/miller/ </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"># owner: root </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"># group: root </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">user::rwx </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">group::r-x </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">other::r-x </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">-------------------- </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">Now we have to set the correct rights for the user "miller"</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">user rights: </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">setfacl -m u:miller:rwx /media/miller</span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"> </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">-------------------- </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">group rights: </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">setfacl -m g:miller:--- /media/miller </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">-------------------- </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">Rest of world: </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">setfacl -m o::--- /media/miller </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">-------------------- </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">At last set mask: </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">setfacl -k --mask /media/miller </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">-------------------- </span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">If everything is correct, it should look like this:</span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"> </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">getfacl /media/miller/ </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">getfacl: </span></span><span style="color:#000000;"><span style="background-color:#ffffff;"><span style="font-
family:monospace;">Removing leading '/' from absolute path names</span></span></span><br /><span style="color:#31363b;"><span style="background-color:#fafafa;"><span style="font-family:Noto Sans;"># file: media/miller/ </span></span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"># owner: root </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;"># group: root </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">user::rwx </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">user:miller:rwx </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">group::--- </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">mask::rwx </span></span></p>
<p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;"><span style="color:#31363b;"><span style="background-color:#fafafa;">other::---</span></span></p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">-------------------</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">I hope this helps a litte bit. </p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">If I described something wrong, please feel free, to correct it! I made this from my remembering and my environment is German.</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Best</p>
<br /><p style="margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;">Hans</p>
<br /><br /><br /></body>
</html>
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)