Setting user permissions for a directory mounted in /etc/fstab - permissions

My embedded Linux system is using an admin user account to make some restricted administration tasks. The home directory for that user is /mnt/foo. That directory is the mount point for a partition mounted by /etc/fstab on boot:
/dev/mmcblk1p6 /mnt/foo ext4 defaults 0 0
The problem is with permissions for that /mnt/foo directory:
$ ls -ld /mnt/foo/
drwxr-xr-x 16 root root 4096 Mar 23 07:54 /mnt/foo/
This permissions don't allow the admin user to create/write any file:
$ pwd
/mnt/foo
$ touch hello
touch: hello: Permission denied
This problem can be easily fixed setting 777 permissions to /mnt/foo in rcS startup script:
$ chmod 777 /mnt/foo
But I don't like this solution. I have tried setting different options in the fstab (gid=admin,uid=admin,umask=000), but it seems these mount options are not supported by ext4 filesystems.
Is the rcS startup script the only feasible way to fix this issue? Thanks!

you can change the default value in the /etc/fstab entry line:
/dev/mmcblk1p6 /mnt/foo ext4 defaults 0 0
to become
/dev/mmcblk1p6 /mnt/foo ext4 file_mode=0755,dir_mode=0755 0 0
or whatever the permissions you want to give

Related

How to debug `podman unshare` commands / Podman permission issues?

I understand that podman unshare can be used to properly set the permissions on unprivileged containers.
So podman unshare chown 1234:1234 -R /home/user/volume can be used to set the volume to the properly mapped ids.
But I'm getting permission errors when I'm trying to do that:
podman unshare chown -R 1234:1234 -R /home/user/foo/bar; echo $?
chown: changing ownership of '/home/user/foo/bar': Operation not permitted
1
The first thing I thought about was directory permissions but it fails even if I'm giving the destination directory 0777.
I'm calling the command as user user and the parent directories have these permissions:
drwxr-xr-x root /home
drwxr-x--- user /home/user
drwxrwxrwx user /home/user/foo
drwxrwxrwx user /home/user/foo/bar
It isn't my intention to really use 0777 in production but something is off even with 0777 and it's not clear to me how to debug this.

How to access \\wsl$\othercontainer\some\file from within a WSL container?

From Windows, I can access the file systems of all the WSL containers from under \\wsl$.
And from inside a WSL container, I can access the windows C:\ drive as /mnt/c.
But how can I access another container's drive from inside a WSL container?
I'm trying to access \\wsl$\othercontainer\some\file from inside a WSL container.
wslpath can normally convert Windows file paths to paths accessible from WSL:
WSL2#~» wslpath 'C:\Windows\System32\drivers\etc\hosts'
/mnt/c/Windows/System32/drivers/etc/hosts
But it doesn't work for:
WSL2#~» wslpath '\\wsl$\othercontainer\some\file'
wslpath: \\wsl$\othercontainer\some\file
WSL2#~» echo $?
1
And of course:
WSL2#~» ls -l '\\wsl$\othercontainer\some\file'
ls: cannot access '\\wsl$\othercontainer\some\file': No such file or directory
This answer provided the answer:
sudo mkdir /mnt/othercontainer
sudo mount -t drvfs '\\wsl$\othercontainer' /mnt/othercontainer
ls -l /mnt/othercontainer/some/file
NOTE: It looks like symbolic links aren't supported. When one is encountered, we get an error like:
$ ls -l /mnt/othercontainer/bin
ls: cannot read symbolic link '/mnt/othercontainer/bin': Function not implemented
lrwxrwxrwx 1 root root 7 Apr 23 2020 /mnt/othercontainer/bin

How do I change the Apache root permission?

Upgrade to PHP 7.1 and getting 403 error. How do I change the root permission to 751?
As the root user, run:
chmod 751 path/to/your/directory/
use the "recursive" option if you want to also modify permissions of all subdirectories:
chmod -R 751 path/to/your/directory/
then do this:
ls -l
This should show that your directory is owned by root and now has permissions "drwxr-x--x".
Source and more details: http://www.filepermissions.com/directory-permission/751

Permissions for webcam access through Apache

I am trying to capture an image through a webcam and display it on a webpage but I am getting "permission denied errors"
I am running apache with the following user/group
/etc/apache2/envvars :
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
In the html code i have the request:
myRequest.open("GET", "/cgi-bin/getImage1.cgi", true);
myRequest.send();
In /usr/lib/cgi-bin I have the file: getImage1.cgi
#!/bin/bash
rm image1.jpg
fswebcam -r 640x400 --no-banner --deinterlace -q -d /dev/video0 --jpeg 95 image1.jpg
The file and directories permissions are:
In /usr/lib drwxrwxrwx 2 root www-data 4096 May 14 19:37 cgi-bin
In /usr/lib/cgi-bin -rwxr-xr-x 1 www-data www-data 115 May 14 18:51 getImage1.cgi
In /dev crw-rw----+ 1 root video 81,0 May 14 18:02 video0
User www-data is a member of the following groups:
$ id www-data
uid=33(www-data) gid=33(www-data) groups=33(www-data),44(video)
When i run the web page i get the following error code:
rm: cannot remove 'image1.jpg': No such file or directory
Error opening device: /dev/video0
open: Permission denied
Unable to find a source module that can read /dev/video0.
End of script output before headers: getImage1.cgi,
The error implies that it is executing the script but that the user does not have sufficient permissions to access the /dev/video0.
The apache user should be www-data which is a member of both www-data and video groups, so it should have access to the /usr/lib/cgi-bin directory, getImage1.cgi file, and the /dev/video0 webcam.
If I execute the script from the console it runs fine.
I would appreciate if anyone can offer suggestions.

Ubuntu Unable to change permisions on windows partition disk

I need to change permissions of files in my /media/MAVEN/Projects
MAVEN is my windows disk partition.
The permissions on the Projects folder are:
:/media/MAVEN/Projects$ ls -la
\total 340
drwxrwxrwx 1 root root 12288 Oct 6 21:31 .
drwxrwxrwx 1 root root 32768 Oct 9 06:32 ..
all the projects are set to drwxrwxrwx
I need to change them to 755 so I tried:
~$ sudo chmod 755 -R /media/MAVEN/Projects
But I get errors: ...Read-only file system
The result of ls -la /media/MAVEN/Projects remains the same.
Help me resolve this.
Problem solved. I found out that I was using a package that was mounting my disk as read only. Its called pysdm I disabled that feature.