0

There are other answers like: centos - Linux: Create a user than can access other users' files - Super User, but they don't talk about accessing those files from GUI application. My question is more broad, as I want to access, read and write other user's files and directory as smoothly as I do for mine.


Background

  • I want to restrict access to certain files and folders owned by my user as I sometimes share my laptop without logging out.

  • Using, How to password protect a folder on Unix/Linux without encryption? - Super User, I created another user:group secure:secure, and I changed the ownership to it. And, I changed files and directory permissions recursively, to let only owner and group read, write and execute for directories; read and write for files.

  • Whenever, I want to use the other files and folders, I want to switch user su - secure.

Problem

  • After switching user when I try to run those files using an application from terminal, I get following errors (both mpv and cvlc work fine from my original user)
$ mpv Hello.mp4

[vo/sdl] SDL_Init failed Error opening/initializing the selected video_out (--vo) device. Video: no video

Failed to create secure directory (/run/user/1001/pulse): No such file or directory Failed to create secure directory (/run/user/1001/pulse): No such file or directory ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default [ao/alsa] Playback open error: No such file or directory [ao/oss] Can't open audio device /dev/dsp: No such file or directory Cannot connect to server socket err = No such file or directory Cannot connect to server request channel jack server is not running or cannot be started JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock [ao/jack] cannot open server Failed to create secure directory (/run/user/1001/pulse): No such file or directory Failed to create secure directory (/run/user/1001/pulse): No such file or directory ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card couldn't open play stream: No such file or directory [ao/sndio] can't open sndio default [ao] Failed to initialize audio driver 'sndio' Could not open/initialize audio device -> no sound. Audio: no audio VO: [gpu] 1280x720 yuv420p

$ cvlc  1.mp4 

VLC media player 3.0.9.2 Vetinari (revision 3.0.9.2-0-gd4c1aefe4d)
[0000556cff4e2d10] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
[0000556cff4ec480] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[0000556cff4ec480] main interface error: no suitable interface module
[0000556cff452670] main libvlc error: interface "dbus,none" initialization failed
[0000556cff516ea0] main interface error: no suitable interface module
[0000556cff452670] main libvlc error: interface "globalhotkeys,none" initialization failed
[0000556cff516ea0] dummy interface: using the dummy interface module...
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
[0000556cff4e2d10] alsa audio output error: cannot open ALSA device "default": No such file or directory
[0000556cff4e2d10] main audio output error: Audio output failed
[0000556cff4e2d10] main audio output error: The audio device "default" could not be used:
No such file or directory.
[0000556cff4e2d10] main audio output error: module not functional
[00007fd7e20afbb0] main decoder error: failed to create audio output
  • In Nautilus, it doesn't even offer me to enter the password for the other user to browse the contents of the other user's directory. It just does nothing.

Question

  1. How can I access, read and write to the other user's files and folders as I do for my own (main) user's files and folders?

  2. Also, the $XDG_RUNTIME_DIR is not getting created when doing su. I used this alternative: systemd - How to create / delete $XDG_RUNTIME_DIR at login / logoff - Unix & Linux Stack Exchange. But why is $XDG_RUNTIME_DIR not getting created and set?

Porcupine
  • 513

1 Answers1

1

You misunderstand the problem. When you switch users, you are that user and have no problems accessing those files.

The errors you see are not related to those files but to the fact that you they are trying to connect to a process that is running already under your normal user. X is configured to block connections by different users and so, when VLC tries to connect to it, it fails, not when it reads the input file.

To solve this you will have to use xauth to add permission for the new 'secure' user to connect to your X11 server. Then you will most likely have to check that the DISPLAY environment variable is setup when you su to the other user, it should be set to your IP address plus :0 (for the first display).

Itai
  • 3,387