date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,519,655,901,000 |
I have a CentOS 6.5 server with a share that is and should be accessable for and from everyone.
All content placed on that share should be accessable by everyone.
So I created a share with this parameters in smb.conf file:
[global]
security = share
[VODSTOR]
comment = VOD Storage Array
path = /storage/internal
browseable = yes
force user = nobody
force group = nobody
writable = yes
create mask = 0666
directory mask = 0777
public = yes
As far as I know, this should give everyone that access this share the ability to create files and folders.
Folders with drwxrwxrwx rights, and files, -rw-rw-rw rights, right?
this seems to work from a windows perspective... folders created there have the drwxrwxrwx permission bits. and files seems to be readable by all.
But when I mount this folder on a Debian Linux machine folders are created with drwxr-xr-x, That I think is weird..
On the debian machinie I mount it via fstab with:
\ \mnt\path\ cifs rw,user=nobody,pass=nobody 0 0
What is wrong there...? Can't seem to find useful info on the web so far.
|
You're almost there. Your mount command is wrong though. It should be this
/mnt/path cifs rw,noperm 0 0
If you leave the user and group unspecified the underlying permissions get applied. The noperm tells the client not to try and "second guess" the access controls. Otherwise you'll find that the local apparent permissions get in the way.
| Samba share open for all to all |
1,519,655,901,000 |
Environment
Ubuntu 14.04 LTS Desktop
Permissions
/media/gal_db$ ls -al
drwxrwx--- 6 admin shared_disk 4096 Aug 15 13:31 .
drwxr-xr-x 6 root root 4096 Aug 13 12:54 ..
drwx------ 3 postgres shared_disk 4096 Aug 15 14:28 database
/media/gal_db$ members shared_disk
gal admin postgres
Remove postgres from shared_disk to limit access to filesystem
sudo deluser postgres shared_disk
Try logging into database as user gal
psql -U gal
Password for user gal:
psql: FATAL: could not access directory "pg_tblspc/16399/PG_9.3_201306121/16401": Permission denied
Re-add postgres user to shared_disk
sudo adduser postgres shared_disk
Try logging into database as user gal again
psql -U gal
Password for user gal:
psql (9.3.5)
Type "help" for help.
gal=>
Success. And confusion.
Questions
Why does postgres need to be a member of shared_disk to access the database directory?
Isn't it enough that postgres is the owner of the database directory?
|
Only the “admin” user and members of the “shared_disk” group
can access the /media/gal_db directory.
So, if you take “postgres” out of the “shared_disk” group,
it can’t even get to the database directory.
| Confusing Directory Permissions |
1,519,655,901,000 |
It seems I removed executability from system binaries, resulting in loads of Permission denied. Do I have to force reboot into host's rescue mode or is there something else I can do while I'm still connected via SSH ? I'm sure forcibly rebooting will cause data loss.
root@rautamiekka:~# find / '(' -iname '*.vpk' -o -iname '*.txt' -o -iname '*.inf' -o -iname '*.bsp' -o -iname '*.so' -o -iname '*.image' -o -iname '*.cfg' -o -iname '*.swf' -o -iname '*.png' -o -iname '*.dds' -o -iname '*.cur' -o -iname '*.vfont' -o -iname '*.tga' -o -iname '*.ico' -o -iname '*.icns' -o -iname '*.db' -o -iname '*.cache' -o -iname '*.rad' -o -iname '*.dylib' -o -iname '*.mp3' -o -iname '*.sfk' -o -iname '*.vmf' -o -iname '*.vmt' -o -iname '*.3ds' -o -iname '*.dxf' -o -iname '*.jpg' -o -iname '*.scr' -o -iname '*.lst' -o -iname '*.vdf' -o -iname '*.gam' -o -iname '*.dsp' -o -iname '*.nut' -o -iname '*.ekv' -o -iname '*.rc' -o -iname '*.raw' -o -iname '*.nav' -o -iname '*.manifest' -o -iname '*.vbf' -o -iname '*.kv' -o -iname '*.vfe' -o -iname '*.doc' -o -iname '*.flt' -o -iname '*.1' -o -iname '*.pak' -o -iname '*.asi' -o -iname '*.xml' -o -iname '*.6' -o -iname '*.lua' -o -iname '*.res' -o -iname '*.ttf' -o -iname '*.mix' -o -iname '*.wav' -o -iname '*.vcs' -o -iname '*.vtf' -o -iname '*.exe' -o -iname '*.cab' -o -iname '*.dll' ')' -executable -type f -exec chmod -v a-x '{}' ';'
mode of `/usr/lib/monodoc/browser.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.atk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.atk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.gdk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.gdk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.glib-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.glib-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.gtk-dotnet/0.0.0.0__35e10195dab3c99f/policy.2.8.gtk-dotnet.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.gtk-dotnet/0.0.0.0__35e10195dab3c99f/policy.2.10.gtk-dotnet.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.glib-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.glib-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.pango-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.pango-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.glib-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.glib-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.atk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.atk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/mono-service/2.0.0.0__0738eb9f132ed756/mono-service.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/mono-service/4.0.0.0__0738eb9f132ed756/mono-service.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.gtk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.gtk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.gdk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.gdk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.gtk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.gtk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.gtk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.gtk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.gdk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.gdk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.glade-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.glade-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.atk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.atk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.gtk-dotnet/0.0.0.0__35e10195dab3c99f/policy.2.4.gtk-dotnet.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.atk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.atk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.gtk-dotnet/0.0.0.0__35e10195dab3c99f/policy.2.6.gtk-dotnet.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.gdk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.gdk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.pango-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.pango-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.8.glade-sharp/0.0.0.0__35e10195dab3c99f/policy.2.8.glade-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.6.glade-sharp/0.0.0.0__35e10195dab3c99f/policy.2.6.glade-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.gtk-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.gtk-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.glade-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.glade-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.glib-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.glib-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.4.pango-sharp/0.0.0.0__35e10195dab3c99f/policy.2.4.pango-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/gac/policy.2.10.pango-sharp/0.0.0.0__35e10195dab3c99f/policy.2.10.pango-sharp.dll' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/3.5/xbuild.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/mono-configuration-crypto/4.0/mono-configuration-crypto.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/al.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/xbuild.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/mcs.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/ilasm.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/mkbundle.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/resgen.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/monop.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/wsdl.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/gacutil.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/mono-service.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/monolinker.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/gmcs.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/RabbitMQ.Client.Apigen.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/mdoc.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/genxs.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/2.0/xsd.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/al.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/secutil.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/dtd2rng.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/httpcfg.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/sqlsharp.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/xbuild.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/svcutil.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/macpack.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/disco.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mconfig.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-api-diff.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-shlib-cop.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/permview.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-cil-strip.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/ccrewrite.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/ilasm.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mkbundle.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/installvst.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/culevel.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/dtd2xsd.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/resgen.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/monop.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/wsdl.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/caspol.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/setreg.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/sqlmetal.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/gacutil.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/browsercaps-updater.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-api-info.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/csharp.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/sgen.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mozroots.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-service.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/soapsuds.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/monolinker.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mod.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/signcode.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/installutil.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/makecert.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/lc.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/dmcs.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/sn.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/mono-xmltool.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/chktrust.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/cert2spc.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/certmgr.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/pdb2mdb.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/RabbitMQ.Client.Apigen.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/genxs.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/xsd.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/mono/4.0/ictool.exe' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/python2.7/dist-packages/twisted/plugins/dropin.cache' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libdeploy.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libj2gss.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libavplugin.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libverify.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libunpack.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libinstrument.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/liblcms.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libzip.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjdwp.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libmlib_image.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libnet.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libsaproc.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjava.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libdcpr.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libnio.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libdecora_sse.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libnpt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjavafx_font_freetype.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libfxplugins.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libprism_sw.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjfxwebkit.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libnpjp2.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjpeg.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/jvm.cfg' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libj2pcsc.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libawt_xawt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libawt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libglass.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libsplashscreen.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjawt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjavafx_font_pango.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libfontmanager.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjsdt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libj2pkcs11.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjavafx_iio.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjavafx_font.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libsctp.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjaas_unix.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjavafx_font_t2k.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libgstreamer-lite.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjava_crw_demo.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjfxmedia.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libawt_headless.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libdt_socket.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libkcms.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libprism_common.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libt2k.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/jli/libjli.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjsound.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libattach.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libmanagement.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjsig.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libprism_es2.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libhprof.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjfr.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libsunec.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/amd64/libjsoundalsa.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/jre/lib/jvm.hprof.txt' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/missioncontrol/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807/eclipse_1502.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/missioncontrol/libcairo-swt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/amd64/libjawt.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/amd64/jli/libjli.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/visualvm/profiler/lib/deployed/jdk16/linux-amd64/libprofilerinterface.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/lib/jvm/java-8-oracle/lib/visualvm/profiler/lib/deployed/jdk15/linux-amd64/libprofilerinterface.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/usr/bin/cpp-4.6' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/lib/klibc-bhN-zLH5wUTKSCGch2ba2xqTtLE.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/lib/i386-linux-gnu/ld-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/lib/i386-linux-gnu/libc-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/lib/i386-linux-gnu/libpthread-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
mode of `/lib/x86_64-linux-gnu/ld-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
#Other lines telling X was removed. Then ...
#§find: `chmod': Permission denied§ many times.
#It seems removing X from some SO files caused this. I didn't think that would cause problems, but it did.
#mode of `/lib/klibc-bhN-zLH5wUTKSCGch2ba2xqTtLE.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
#mode of `/lib/i386-linux-gnu/ld-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
#mode of `/lib/i386-linux-gnu/libc-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
#mode of `/lib/i386-linux-gnu/libpthread-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
#mode of `/lib/x86_64-linux-gnu/ld-2.15.so' changed from 0755 (rwxr-xr-x) to 0644 (rw-r--r--)
root@rautamiekka:~# find / '(' -iname '*.vpk' -o -iname '*.txt' -o -iname '*.inf' -o -iname '*.bsp' -o -iname '*.so' -o -iname '*.image' -o -iname '*.cfg' -o -iname '*.swf' -o -iname '*.png' -o -iname '*.dds' -o -iname '*.cur' -o -iname '*.vfont' -o -iname '*.tga' -o -iname '*.ico' -o -iname '*.icns' -o -iname '*.db' -o -iname '*.cache' -o -iname '*.rad' -o -iname '*.dylib' -o -iname '*.mp3' -o -iname '*.sfk' -o -iname '*.vmf' -o -iname '*.vmt' -o -iname '*.3ds' -o -iname '*.dxf' -o -iname '*.jpg' -o -iname '*.scr' -o -iname '*.lst' -o -iname '*.vdf' -o -iname '*.gam' -o -iname '*.dsp' -o -iname '*.nut' -o -iname '*.ekv' -o -iname '*.rc' -o -iname '*.raw' -o -iname '*.nav' -o -iname '*.manifest' -o -iname '*.vbf' -o -iname '*.kv' -o -iname '*.vfe' -o -iname '*.doc' -o -iname '*.flt' -o -iname '*.1' -o -iname '*.pak' -o -iname '*.asi' -o -iname '*.xml' -o -iname '*.6' -o -iname '*.lua' -o -iname '*.res' -o -iname '*.ttf' -o -iname '*.mix' -o -iname '*.wav' -o -iname '*.vcs' -o -iname '*.vtf' -o -iname '*.exe' -o -iname '*.cab' -o -iname '*.dll' ')' -executable -type f -print
-bash: /usr/bin/find: Permission denied
root@rautamiekka:~# which find
-bash: /usr/bin/which: /bin/sh: bad interpreter: Permission denied
root@rautamiekka:~# chmod
-bash: /bin/chmod: Permission denied
root@rautamiekka:~# ls
-bash: /usr/bin/ionice: Permission denied
root@rautamiekka:~# reboot
-bash: /sbin/reboot: Permission denied
root@rautamiekka:~# poweroff
-bash: /sbin/poweroff: Permission denied
root@rautamiekka:~# echo
root@rautamiekka:~# echo $
$
root@rautamiekka:~# echo $
$_ $BASH_SUBSHELL $HISTSIZE $LS_COLORS $RANDOM
$BASH $BASH_VERSINFO $HOME $MACHTYPE $_scp_path_esc
$BASH_ALIASES $BASH_VERSION $HOSTNAME $MAIL $SECONDS
$BASH_ARGC $COLUMNS $HOSTTYPE $MAILCHECK $SHELL
$BASH_ARGV $COMP_WORDBREAKS $IFS $OPTERR $SHELLOPTS
$BASH_CMDS $DERBY_HOME $J2REDIR $OPTIND $SHLVL
$BASH_COMMAND $DIRSTACK $J2SDKDIR $OSTYPE $SSH_CLIENT
$BASH_COMPLETION $EUID $JAVA_HOME $PATH $SSH_CONNECTION
$BASH_COMPLETION_COMPAT_DIR $GROUPS $LANG $PIPESTATUS $SSH_TTY
$BASH_COMPLETION_DIR $__grub_script_check_program $LESSCLOSE $PPID $TERM
$BASH_LINENO $HISTCMD $LESSOPEN $PS1 $UID
$BASHOPTS $HISTCONTROL $LINENO $PS2 $USER
$BASHPID $HISTFILE $LINES $PS4 $XDG_SESSION_COOKIE
$BASH_SOURCE $HISTFILESIZE $LOGNAME $PWD
|
If you know what directories were affected -- looks like you do -- you can run, e.g.:
chmod -R 755 /usr/bin
-R is recursive. This should be fine for everything in a bin directory. If chmod itself is affected, you could try this on it, or else boot the box with a live CD and use that.
| What to do when you removed execute permission from some system binaries or libraries? |
1,401,285,063,000 |
It seems somewhat similar to the question here but I think what I'm asking is a little different.
I've got a CentOS 5.x box running with mysql on it. The root linux user can edit/modify files in /var/lib/mysql/ sub-directories but most (if not all) of these directories have file system ownerships of mysql:mysql.
When I run groups root I see:
[root@foo ~]# groups root
root : root bin daemon sys adm disk wheel
I get that root is a privileged account and can/will have access to everything but why don't I see mysql in the list of groups it belongs to?
|
The definition of the root user dictates that it has control over all files on the disk, irregardless of the user's & groups that own said files & directories.
Many Unixes, such as Solaris, used to have a limitation where users could not be in more than 15 groups. NIS another technology for sharing user/group/automounting information also had this limitation.
So typically you would not see the root user in these groups. For one it wasn't possible to do so (given this limit), and also it was not needed for the root user to access files/directories with other ownership anyway. Additionally it's often considered bad design to have all your services/daemons running as root, instead they would each be governed by their own dedicated users & groups.
So the simple answer to your question is root doesn't need to be in those groups because it can do anything it wants to the files/directories on a system, it's the master owner and has complete dictatorship over the files that are local to the system.
So then why is root in any groups?
This is more of a historical practice where you used to see root in several key groups. This is being phased out, to my knowledge, and most of the newer systems that I've supported no longer have this, since it's completely unnecessary now.
Fedora 19
$ groups root
root : root
CentOS 6
$ groups root
root : root bin daemon sys adm disk wheel
NOTE: The primary purpose you'll often times see root in other groups is to allow root to create files within these groups directly, without having to do a chgrp or chown after creating files in directories that are grouped to one of these groups afterwards. When root needs to assume one of the other groups it can run a simple newgrp <group> to switch if needed, or respect a directory that already has the SGID bit on a directory.
References
How does the sticky bit work?
How do the internals of sudo work?
| Why does the root user have control over mysql directories but not show as a member of the mysql group? |
1,401,285,063,000 |
I'm trying to get NFS working properly on a DD-WRT install using OTRW2. I can see and mount the share from the client. But when I do, the mounted folder changes it's owner to root:root and so my normal user does not have write access.
I saw this post by Frater (the original author of the scripts), in which he says that the unfsd service is running as www-data:www-data and that the share should be chowned.
However when I try chowning the /mnt symlink or the /tmp/mnt mount, I receive the following:
root@router:~# sudo chown www-data:www-data /mnt
changing ownership of `/mnt': Operation not permitted
root@router:~# sudo chown www-data:www-data /tmp/mnt
changing ownership of `/tmp/mnt': Operation not permitted
My mounts look like this:
root@router:/opt# mount
rootfs on / type rootfs (rw)
/dev/root on / type squashfs (ro)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
ramfs on /tmp type ramfs (rw)
devpts on /dev/pts type devpts (rw)
devpts on /proc/bus/usb type usbfs (rw)
/dev/discs/disc0/part1 on /opt type ext3 (rw,noatime,data=ordered)
/dev/sda3 on /tmp/mnt type vfat rw,noatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
I've tried the default exports file as well as this:
root@router:~# cat /opt/etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
/mnt 192.168.1.0/24(rw,sync,no_subtree_check,all_squash)
# default
#/mnt 192.168.0.0/255.255.0.0(rw,no_root_squash)
On the client I have a directory that starts out as:
drwxr-xr-x 2 kyle users 4096 Feb 16 09:43 NAS
I've tried from the command line:
kyle@client:~$ sudo mount -v -t nfs router:/mnt NAS
mount.nfs: timeout set for Sun Feb 16 14:09:17 2014
mount.nfs: trying text-based options 'vers=4,addr=192.168.1.1,clientaddr=192.168.1.117'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'addr=192.168.1.1'
mount.nfs: prog 100003, trying vers=3, prot=6
mount.nfs: trying 192.168.1.1 prog 100003 vers 3 prot TCP port 2049
mount.nfs: prog 100005, trying vers=3, prot=17
mount.nfs: trying 192.168.1.1 prog 100005 vers 3 prot UDP port 2049
And with various fstab lines:
# router NAS mounting
router:/mnt /home/kyle/NAS nfs auto 0 0
#router:/mnt /home/kyle/NAS nfs rsize=8192,wsize=8192,timeo=14,intr,_netdev,nfsvers=3 0 0
But the folder always ends up as:
drwxr-xr-x 10 root root 16384 Dec 31 1969 NAS
What do I need to do to make the NFS share writable from the client side?
|
You cannot change permissions on this mount:
/dev/sda3 on /tmp/mnt type vfat rw,noatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1)
Notice the type is VFAT. You can only change permissions using chmod on EXT type permissions, or ones that actually support it.
You can either reformat it as EXT4, mkfs.ext4, or using something like Samba to provide access to it the underlying /tmp/mnt.
| NFS Ownership/Permissions |
1,401,285,063,000 |
I have a situation on a Linux machine that I can't really explain.
Some background: We're running apache with a c/c++ module that forwards requests to our application. It does so by reading a .port file which specifies a local port to send the requests to.
After installation, it is not possible to connect using the web interface. After a bit of troubleshooting I bring out strace and see that the apache processes fail to read the .port file:
[pid 8105] stat("/tmp/somedir/application.port", 0x7ffff9694470) = -1 EACCES (Permission denied)
I check the permissions on the file:
% ls -l /tmp/somedir/application.port
-rw-r--r--. 1 appuser staff 5 Oct 16 14:10 application.port
So, anyone should be able to read that, right?
I check who the apache process runs as:
% ps -ef | grep 8105
appuser 8105 3357 0 15:14 ? 00:00:00 /usr/sbin/httpd
So the apache process runs as the owner of the file. That should work too, right?
Finally, I do:
% su - appuser
% stat /tmp/somedir/application.port
File: `/tmp/somedir/application.port'
Size: 5 Blocks: 8 IO Block: 4096 regular file
Device: 11h/17d Inode: 1400293 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1001/ appuser) Gid: ( 1001/ staff)
Access: 2013-10-16 14:10:03.357679902 +0200
Modify: 2013-10-16 14:10:03.357679902 +0200
Change: 2013-10-16 14:10:03.357679902 +0200
So, the "appuser" owns the file, runs the web server, but don't have the permission to do stat() on it from within the web server process?
Does anyone have an idea about what could be going on here?
I should also mention that this is not the first installation we've done, and the others work as expected. There might have been some manual fiddling during the installation of this particular machine, but I still don't see how we can end up like this.
Restarting processes also does nothing to change the behavior.
The machine is a RHEL 6 box.
|
In the end, it turned out that the problem was indeed SELinux-related.
For anyone else who might need to get a quick understanding of what SELinux is and some useful commands, I recommend the SELinux for mere mortals youtube video. It's a great introduction to get started with troubleshooting.
| EACCES that should not happen |
1,401,285,063,000 |
I have changed my DocumentRoot to /home/user/www. To achieve that I have just changed the 2 occurrences of the path at /etc/apache2/sites-available/default.
The permissions of /home/user/www are 0774. I have added the www-data user to my user's group and the owner of /home/user/www is my own user and group (user:user).
I have done that by:
sudo chmod -R 0774 www
sudo chown -R user:user www
sudo adduser www-data user
The problem is that Apache can't write to this directory. It can write only if I set www-data as owner, but if I do that, I can't write at the directory.
I have tested the permissions with:
sudo -u www-data ls /home/user/www
sudo -u www-data cat /home/user/www/some-file
and it works.
But the Wordpress I have at www can't delete or create files. Any ideas?
|
You would have been better off with the www directory at /var/www, with owner www-data and group www-data, and adding your user to the www-data group.
First, change the DocumentRoot etc back to /var/www in the apache config.
The /var/www directory (and all subdirectories in it) should be setgid, so that files and dirs are created with group www-data.
All of the following should be run as root, or with sudo:
mkdir -p /var/www
if there were any files in /home/user/www that you want to keep, move them to /var/www now with:
mv /home/user/www/* /var/www/
Now fix the permissions and ownership of the /var/www directory.
chown -R www-data:www-data /var/www
chmod -R 775 /var/www
find /var/www -type d -print0 | xargs -0r chmod g+s
adduser user www-data
The next time 'user' logins in (or runs newgrp www-data), they should have write permission in /var/www
BTW, if you want to make it easy for 'user' to find the web files, just make a symlink in their home directory:
ln -s /var/www/ /home/user/
| Apache2 permissions issue |
1,401,285,063,000 |
How can I achieve this files & folders permissions scenario:
Consider these folder:
Folder A: 640 root apache /var/www/A/
Folder www: 640 root apache /var/www/
and this linux user:
id user1: uid=1000(user1) gid=1000(user1) groups=1000(user1)
I want to allow linux user user1 read/write access JUST to folder A, BUT don't change folder A owner or group.
I have tried these scenarios but none of them were desirable:
add user1 to group apache:
cons: user1 will be able to read other files at /var/www/.
hard-link a folder(ex. folder B) in user1's home to /var/www/A/ and set proper permissions on folder B rather than A:
cons: hard-links to directories not possible on cross-devices.
add user1 to sudoers:
cons: complexity of user1, plus, user1 may broke owner/group policy and/or permissions of folder A by human-error.
any idea?
|
I'm assuming you want to give user1 access to /var/www/A because you visit the content managed by user1 via http://your.domain/A? Why not have apache redirect the content to a directory under the users home directory?
Alias /A/ /path/to/users/homedir/A
This will achieve the result and not have to change group/user ownership/permissions of the /path/to/users/homedir/A.
However if you want to do it by file permissions, you will only be able to achieve it by changing ownership/permissions of /var/www and /var/www/A.
Create a 'new group' (most unixes provide a groupadd command), add both apache and user1 to it. Change the group ownership of /var/www/A to this 'new group' (with either chown or chgrp). Set the permissions to disallow access to rw for 'new group' and 'other users' to the /var/www directory (chmod 711 /var/www) and give access to the 'new group' for /var/www/A (chmod g+rwx /var/www/A).
References:
Apache Alias Directive
| FS permission scenario |
1,401,285,063,000 |
Are there any good documentation, HOWTOs or books (preferably free and online) describing the permission-mechanism for Solaris/OpenIndiana? How auths, profiles, roles, projects, groups and users relate to each other... how to use the mechanism optimally... and what exactly the various named auths, profiles and roles actually are allowed to do, and what users should be assigned them and why?
|
Joerg Moellenkamp's blog always has some nice insights. He wrote a little PDF booklet --"Less Known Solaris Features," which presents a narrative/examples on how to combine these features for use with least privilege and access control. Its all in the chapter on security.
| Solaris/OpenIndiana: Good documentation for permission-mechanism - roles, profiles and auths? |
1,401,285,063,000 |
I'm attempting to build a box via Fabric on Openstack. Part of the install involves installing and running PostgreSQL.
This command works fine:
$ sudo service postgresql initdb
This command fails:
$ sudo service postgresql start
Log output of failure shows no issues when I run this command:
$ cat /var/lib/pgsql/pgstartup.log
This command shows the following messages:
$ cat /var/lib/pgsql/data/pg_log/postgresql-Wed.log
LOG: could not open configuration file
"/var/lib/pgsql/data/pg_hba.conf": Permission denied
FATAL: could not load pg_hba.conf
My user while executing these commands has the following groups:
vagrant, wheel
My user is in the sudoers list under /etc/sudoers with these permissions:
vagrant ALL=(ALL) NOPASSWD: ALL
perms on pgsql:
[root@integration ~]# ls -ltr /var/lib/pgsql/
total 12
drwx------. 2 postgres postgres 4096 Sep 13 2012 backups
-rw-------. 1 postgres postgres 1152 Jun 19 20:17 pgstartup.log
drwx------. 12 postgres postgres 4096 Jun 19 20:19 data
and sub dir data:
[root@integration ~]# ls -ltr /var/lib/pgsql/data/
total 76
-rw-------. 1 postgres postgres 4 Jun 19 20:17 PG_VERSION
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_twophase
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_tblspc
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_stat_tmp
drwx------. 4 postgres postgres 4096 Jun 19 20:17 pg_multixact
-rw-------. 1 postgres postgres 16886 Jun 19 20:17 postgresql.conf
-rw-------. 1 postgres postgres 1631 Jun 19 20:17 pg_ident.conf
drwx------. 3 postgres postgres 4096 Jun 19 20:17 pg_xlog
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_subtrans
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_clog
drwx------. 5 postgres postgres 4096 Jun 19 20:17 base
drwx------. 2 postgres postgres 4096 Jun 19 20:17 global
-rw-------. 1 postgres postgres 241 Jun 19 20:17 pg_hba.conf
drwx------. 2 postgres postgres 4096 Jun 19 20:17 pg_log
-rw-------. 1 postgres postgres 57 Jun 19 20:19 postmaster.opts
|
This turned out to be an selinux issue.
I disabled it and was well. Full config below.
For those of you that arent up on selinux (like me until today) the config can be found in:
/etc/selinux/config
It can also be turned off temporarily like this:
echo 0 > /selinux/enforce
Full config
[root@integration selinux]# cat config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
| postgresql service start issues |
1,401,285,063,000 |
Recently my wireless network has being stopping to transfer data from some irregular time intervals that vary from 30 seconds to 20 minutes, and every time I need to plug off and then on the wireless adapter.
Using ping (ping 8.8.8.8) to see what happens, and when data transfer stops I receive this message:
ping: sendmsg: No buffer space available
So I found out that a solution for this is to increase buffer size with this command:
sudo echo 83886080 > /proc/sys/net/core/wmem_max
Although I can't execute this command, when I hit enter I get this:
bash: /proc/sys/net/core/wmem_max: Permission denied
Trying the command without sudo or with gksu returns the same message. Through GEdit I can open /proc/sys/net/core/wmem_max file, and opening as administrator it enables me to click the 'Save' button, although after changing the value and hitting the button it returns me this message:
Could not create a temporary backup file while saving /proc/sys/net/core/wmem_max
gedit could not backup the old copy of the file before saving the new
one. You can ignore this warning and save the file anyway, but if an
error occurs while saving, you could lose the old copy of the file.
Save anyway?
And even clicking in the 'Save anyway' button it returns the very same message.
|
Your sudo command does not write the data as root. Only executes echo as root.
Try
sudo -s -H
echo 83886080 > /proc/sys/net/core/wmem_max
| Can't edit /proc/sys/net/core/wmem_max [duplicate] |
1,401,285,063,000 |
While using Debian squeeze, I was able to allow a user shutdown in xfce by adding users to the powerdev group (see here: xfce: Allow shutdown for non-root users).
Now, I upgraded my system to Debian wheezy, and some stuff in xfce doesn't seem to be running smoothly as it used to, most notably the shutdown process. Clicking on the logout icon will take me to the logout screen with "logout" enabled and "restart/shutdown" being greyed out.
This thread on the xfce forum seems to mention the same problem.
The same seems to be true for access to USB drives: Even though users are in the plugdev group, permission to the external volumes is denied (the do show up in thunar or whatever file managers are used, however).
This thread on lists.debian.org seems to mention the same problem.
The old version of xfce4 (with squeeze) was 4.6, the new version of xfce4 (with wheezy) is 4.8.
Have the config files changed? Does the newer version of xfce not care about the powerdev group any more? Any hints on troubleshooting/debugging?
|
I had this problem too; a solution on the Debian mailing list works for me. Make these two files:
/etc/polkit-1/localauthority/50-local.d/consolekit.pkla
[restart]
Identity=unix-user:*
Action=org.freedesktop.consolekit.system.restart
ResultAny=yes
[stop]
Identity=unix-user:brian
Action=org.freedesktop.consolekit.system.stop
ResultAny=yes
/etc/polkit-1/localauthority/50-local.d/udisks.pkla
[udisks]
Identity=unix-user:*
Action=org.freedesktop.udisks*
ResultAny=yes
This part of the thread on lists.debian.org explains the underlying reasons why this is necessary.
| Xfce: Upgrade from Squeeze to Wheezy broke xfce's user policies |
1,401,285,063,000 |
I've been trying to figure out the proper location to set daemon umasks in RedHat 5. All my searches lead to setting it in /etc/init.d/functions or /etc/sysconfig/init.
What are the pros/cons of setting the umask in one place over another? Is one location more secure than the other?
|
I would set it in /etc/sysconfig/init because that gets sourced later on in the .etc/init.d/functions script than the explicit umask command does and as such it takes precedence.
Not to mention /etc/init.d/functions is a script file whereas /etc/sysconfig/init is a configuration file. Scripts may be updated by rpm but newer config files just get saved as configFileName.rpmnew. So if you change it in functions, an update may things cause things to start breaking and it will be non-intuitive to figure out why.
| Properly Setting Red Hat Daemon Umask |
1,401,285,063,000 |
I have a 3TB external hard drive that I plan to use for backups. I originally tried formatting with cfdisk, until I learned that only GPT supports 2TB+ partitions.
So I converted the drive to GPT and formatted the one partition I made to ext4, but I keep getting "Permission Denied" errors. Normally, udiskie is able to automount everything such that I don't see write errors such as this.
I feel like my lack of knowledge about GPT might be contributing to some oversight, but I'm not sure what might be wrong.
|
When you format disk partition with native filesystem, the permissions to directory you mount it will be the same as permissions to root directory of that partition. Permissions to mount directory itself usually have no sense.
Some filesystems have mount flags allowing to change permissions (that's usefull for example for USB sticks).
Mounting of non-native filesystems (vfat, ntfs) works by different way: you can give options to mount to set owner of files on mounted volume & permissions to that files.
I recommend you to read man mount for clearance.
In common case, when you have a native filesystem on a removable device, you should to make similar UID's and GID's at least for yourself on all computers where this device will be mounting. Otherwice you should make from root chmod -R a+rwX /mountpoint/of/device after mounting it and in future not to make files and directories with permissions other than 666 and 777 respectively.
| External HD: "Permission Denied" on file write |
1,401,285,063,000 |
I would like the following result on my UNIX system:
ls -l /users/test -> permission denied, or any other way so I can't see the content of it.
ls -l /users/test/testdir/ -> shows all files in the directory
Do you have any solutions for this?
|
By leaving only execute permissions on the parent folder and normal permissions on the child directory, you can enter the parent directory but be unable to view its contents unless you know the exact filename.
eg
mkdir -p a/b
touch a/{1,2,3} a/b/{p,o,i}
chmod 111 a
ls -la a #Permission denied
ls -la a/b #Lists i and o and p
| Hide parent directory but allow to view dir |
1,401,285,063,000 |
I wrote a package, and would like to use /var to persist some data. The data I'm storing would perhaps even be thought of as an addition for /var/db.
The pattern I observe is that files in /var/db, and the surrounds, are owned by root. The primary (intended) use of the package filters cron jobs - meaning you would need permissions to edit the crontab.
Should I presume a sudo install of the package?
Should I have the package gracefully degrade to a /usr subdir, and if so then which one?
If I 'opinionate' that any non-sudo install requires a configrc (with paths), where should the package look (presuming a shared-host environment) for that config file?
Should I use /usr/lib as per the thoughts in this article?
Incidentally, this package is a ruby gem, and you can find it here.
|
If that package is installed as root it has access to /var.
If it's installed by a user (who can neither write to /var nor /usr) the default procedure is to set --prefix=$HOME/somedir in the configure script. Or you provide other means to set the directory to a location the user has write access to.
| Do best-practices indicate that usage of /var should be restricted to sudoers |
1,401,285,063,000 |
I have Nagios running on a webserver. For this one Nagios service check in particular, if it fails, it will run a script. This script is triggered via Nagios event handlers.
Nagios event handler command:
define command{
command_name testDisableServer
command_line /usr/local/nagios/etc/objects/event_handlers/testDisableServer.sh
}
I am executing a script called testDisableServer.sh from Nagios event handlers that looks like this:
#!/bin/bash
wall "Script execution started";
/usr/bin/sudo /root/scripts/disableServer.sh force
This script 'testDisableServer.sh' has the following permissions:
-rwxr-xr-x 1 nagios nagios 2.0K Oct 12 14:57 testDisableServer.sh
When the service goes down, I will get a wall post in my SSH connection saying "Script execution started", but it will not trigger my disableServer.sh script. I tried to place another wall post inside of disableServer.sh and it did not trigger it.
This script is being run by the user 'nagios'. 'nagios' was added in visudo, as such:
nagios ALL=(ALL)NOPASSWD:/root/scripts/disableServer.sh
Running this script as the user 'nagios' from a command line works perfectly fine. However, when the event handler triggers it, there is no output. I tried to catch the output into a log file, and I came up with nothing. These are the permissions on /root/scripts/disableServer.sh:
-rwxr-xr-x 1 root root 2.0K Oct 12 15:01 disableServer.sh
Why would the event handler hit 'testDisableServer.sh', but not execute 'disableServer.sh' from a Nagios event handler, but work just fine in an SSH connection as the user nagios? BTW, 'testDisableServer.sh' is just an extra layer added to see if the event handlers were working, which they seem to be. This will be removed after this script execution is all sorted out.
|
Possibly it's an environment issue (the script is relying on something in its environment that is not available when run by nagios).
I would change your script (temporarily for debugging only) to:
#! /bin/bash -
exec 2> /tmp/log."$$"
set -x
wall "Script execution started";
/usr/bin/sudo /root/scripts/disableServer.sh force
And add another set -x at the top of disableServer.sh
To see what's going on (in the /tmp/log.* files).
| Executing a script from Nagios event handler fails to run |
1,401,285,063,000 |
A few weeks ago, I installed Linux Mint on a USB flash drive. I used it to copy the contents of my HFS+ external hard drive to my Windows drive on my desktop. Then, I formatted the external drive to install linux on it, as well as create a large HFS+ partition. I copied the contents back from the windows drive to the new HFS+ partition on the external drive. Now, half of the files' permissions are acting weird. For example, on the drive, "/Files" is drwxrwxrwx, and if I copy something that's -rw-r--r--@ from my Desktop on my Mac laptop into "/Files" on my external drive, it remains -rw-r--r--@, but I can't rename, modify, or delete it. Why might this be? I do not have admin/root access on my mac, but I do on my Linux install. I've run "chmod -R 777" on the entire drive on my linux install, and I can modify these files there, but the permissions still act weird when it's on my Mac. Is this because there are different users and groups on my Mac?
|
On a mode line, '@' usually means extra attributes, and '+' means extra permissions. OS X uses both of these extensively, whereas Linux tends not to (especially for permissions).
On OS X, you can view these using ls -le@, where -l is long output, -e shows access control, and -@ shows extra flags (some of which may prevent modification to a file even if its permissions allow it).
On Linux, you can view attributes with lsattr or lsattr -l (long output, more human-friendly). Then you can change them, if needed, using chattr. In particular, you may be interested in the i (immutable) attribute, which prevents modifications to files.
You can deal with Linux ACLs using the getfacl and setfacl commands, but you may have to install those tools, and your filesystem may not support them anyway.
| Permissions corrupted? |
1,401,285,063,000 |
I am learning Linux for work, so am still a bit rusty on the edges.
I need to change the folder permission of the directory /opt, and I know in Linux, you do the following:
chmod 775 /opt
I get a message under that saying:
chmod: WARNING: cannot change /opt/: Operation not permitted (error 1).
Does that mean I need sudo permissions? But the sudo command is not recognized.
But in SCO, it is different, as SCO is a little older than Ubuntu.
I have found this link on the net, but don't quite understand what they mean by "memo": Changing file permissions.
Is there an easier way of doing this, like something similar to Linux?
|
That message means you don't have sufficient privileges on the system to change the mode of the directory. If sudo is not installed on the system, you will need to gain elevated privileges using su (you'll need the root password), when you will be able to use chmod in exactly the way you would on Linux - using either absolute or symbolic permissions.
If you don't have the root password, you will need to ask someone who has sufficient privileges to make the change for you. Depending on local policy, a request to have sudo installed and configured may or may not work.
EDIT
From an answer to your other open thread, it seems that SCO has a command called asroot, which serves a similar purpose to sudo elsewhere.
| Gaining root privileges in SCO |
1,401,285,063,000 |
I have a several users on one machine and its needed to specify which user can access (read & write) specified folders and/or mounted drives.
First of all, one user shouldn't see a home/<%username%>/ of another user.
edit:
I'll try to explain very simply:
Lets say we have two users: steven and john. Both of them have some private data under their directories: john/private, john/Desktop, steven/private, steven/Desktop.
I would like to prevent that steven can access (read or write) under john/ dir and prevent john to read/write under steven/dir.
i'm hope so I'm clear enough :)
|
This is, in general, not possible on Unix. If being able to see the directory but not listing the contents is acceptable (it probably is), then set the mode so that the user affected does not have the read bit set on their modes for that directory (700 or similar).
| How to set permissions what users can see (drives, folders) on opensuse 12.1? |
1,401,285,063,000 |
I recently installed a new SSL certificate and then also decided to tighten security a bit by make the private key less readable.
This caused a problem with exim.
The certificate is now 640 with user root and group ssl. The user Debian-exim is in this group.
I can access the private key file just fine from the shell:
#sudo -u Debian-exim cat key
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
However, the log file of exim says otherwise:
2012-04-21 00:00:00 <Message-id> unable to open private key file for reading: /.../key
2012-04-21 00:00:00 <Message-id> == some@email <some@email> R=dnslookup T=remote_smtp defer (-1): smtp transport process returned non-zero status 0x0100: exit code 1
2012-04-21 00:00:00 <Message-id> Frozen
Using auditd I checked the filesystem access:
time->Sat Apr 21 00:00:00 2012
type=PATH msg=audit(1335027881.290:6): item=0 name="/.../key" inode=1794200 dev=09:01 mode=0100640 ouid=0 ogid=105 rdev=00:00
type=CWD msg=audit(1335027881.290:6): cwd="/var/spool/exim4"
type=SYSCALL msg=audit(1335027881.290:6): arch=c000003e syscall=2 success=no exit=-13 a0=16184f8 a1=0 a2=0 a3=0 items=1 ppid=11831 pid=11847 auid=4294967295 uid=100 gid=102 euid=100 suid=100 fsuid=100 egid=102 sgid=102 fsgid=102 tty=pts1 ses=4294967295 comm="exim4" exe="/usr/sbin/exim4" key="sslkey"
Which shows that it indeed fails (though I don't know why). In comparison an as-identical-as-possible successfull calle (file group is changed to Debian-exim as opposed to ssl)
time->Sat Apr 21 00:00:00 2012
type=PATH msg=audit(1335028586.882:34): item=0 name="/.../key" inode=1794200 dev=09:01 mode=0100640 ouid=0 ogid=102 rdev=00:00
type=CWD msg=audit(1335028586.882:34): cwd="/var/spool/exim4"
type=SYSCALL msg=audit(1335028586.882:34): arch=c000003e syscall=2 success=yes exit=11 a0=24f74f8 a1=0 a2=0 a3=0 items=1 ppid=13958 pid=13961 auid=4294967295 uid=100 gid=102 euid=100 suid=100 fsuid=100 egid=102 sgid=102 fsgid=102 tty=(none) ses=4294967295 comm="exim4" exe="/usr/sbin/exim4" key="sslkey"
I have no idea what goes wrong. Why can the exim daemon access the "key" file when the file group is Debian-exim (primary group of Debian-exim user) but not when the file group is ssl (a secondary group of Debian-exim user)?
|
The groups that a user is in are granted by the login process. When a daemon switches to a user and group after launch, it typically only switches to this user and group (with setgid followed by setuid), and doesn't take on any other group implied by /etc/passwd (primary group) and /etc/group (supplementary group). I haven't checked that exim behaves this way, but if it doesn't, it's unusual.
You can check what groups the exim process is running as by running grep '^Groups:' /proc/1234/status where 1234 is the PID of an exim process.
You need to make the key file readable by either the Debian-exim user or the Debian-exim group. Make sure ACLs are turned on, then add Debian-exim to the ACL of the key file and any non-public directory leading to it:
setfacl -m group:Debian-exim:r /path/to/key
setfacl -m group:Debian-exim:x /path/to
| Daemon file access denied while it shouldn't |
1,401,285,063,000 |
I am trying to change the ownership of a folder and all its contents to www-data, but am being denied permission to change it. I am root. and I've tried using sudo but nothing works.
eyedea@eyedea-ER912AA-ABA-SR1810NX-NA620:/var/www$ chown -R www-data.www-data /var/www/drupal/
chown: changing ownership of `/var/www/drupal/scripts/run-tests.sh': Operation not permitted
chown: changing ownership of `/var/www/drupal/scripts/code-clean.sh': Operation not permitted
chown: changing ownership of `/var/www/drupal/scripts/drupal.sh': Operation not permitted
|
If /var/www/drupal is an NFS mount and rootsquash is enabled, you will get an error such as this. You'll have to make this change from the NFS server directly, or make the change as the existing non-root owner of these files.
It could also be that write permissions are not enabled on the files you are getting an error with. Make sure the write bit is flipped for at least the owner of the file.
| Denied permission to change ownership |
1,401,285,063,000 |
When I change permissions for other or user on a setgid directory, the directory loses its setgid. How do I make the change without loosing it? sudo is not an option. Is it possible?
Here is some context.
$ whoami
webmin
$ groups
webmin
$ echo $SHELL
/bin/bash
$ uname -srvm
Linux 2.6.38-12-server #51-Ubuntu SMP Wed Sep 28 16:07:08 UTC 2011 x86_64
Here is an example.
$ ls -la
drwxr-s--- 4 webmin www-data 4096 2011-11-03 10:59 .
drwxr-s--- 4 webmin www-data 4096 2011-10-26 15:53 ..
$ mkdir libraries
$ ls -ld libraries
drwxr-sr-x 2 webmin www-data 4096 2011-11-03 11:01 libraries
$ chmod o= libraries
$ ls -ld libraries
drwxr-x--- 2 webmin www-data 4096 2011-11-03 11:01 libraries
^
`- The problem
The same happens if I modify the user's permissions on the directory.
The following fails too.
$ chmod g=rxs,o= libraries
=== UPDATE ====
Kevin's answer led me to what I believe is the cause of the problem. Apparently, you must be a member of the group assigned to the file. For example
$ whoami
webmin
$ groups
webmin www-data <---- Now we are in the www-data group.
$ mkdir t
$ ls -ld t
drwxr-sr-x 2 webmin www-data 4096 2011-11-03 12:03 t
$ chmod o= t
$ ls -ld t
drwxr-s--- 2 webmin www-data 4096 2011-11-03 12:03 t
^
`- Yeah!
So is the answer is "yes" as long as you are a member of the group, otherwise "no"?
|
If you are not a member of the group assigned to the directory, then if you modify any permissions, you will lose setgid on that directory.
Options
You could change your umask before you create the directory, avoiding the need to modify the permissions on the directory after you create it. That way you won't lose setuid on that directory. (Demonstrated at the end of this answer.)
Become a member of the group (requires sudo)
$ sudo usermod -a -G www-data webmin
Change the permissions using sudo
$ chmod g=rxs,o= libraries
The last two violate the constraints of the question, so the answer is option 1.
$ umask 0027
$ mkdir libraries
$ ls -ld libraries
drwxr-s--- 2 webmin www-data 4096 2011-11-03 12:03 libraries
| How do I change permissions on a directory without losing setgid? |
1,401,285,063,000 |
I just did something pretty simple. Given a user user, I modified his user id, primary group's id, and added him to a new group in order to make my server use the same uid and gid as another server which shares files with this server over NFS. (I was told that I needed to do this in order to keep permissions from going insane on the shared files.)
What I did is the following:
groupadd -g 2000 mygroup
groupmod -g 1500 user
usermod -u 500 -g 1500 -G 1500,2000 user
This accomplished the following:
The user's ID now matches the remote user's ID so NFS permissions will work.
The user's primary group ID now matches the remote user's primary group ID.
The user now belongs to group mygroup which the remote user is also a part of.
Now, unfortunately, I can't su -l user, as I get the following error:
grep: /var/cpanel/users/user: Permission denied
I don't think that I did anything wrong, as when I id user, then everything looks fine:
uid=500(user) gid=1500(user) groups=1500(user),2000(mygroup)
What gives? Why am I getting this cPanel-ish error? What did I do wrong here/forget to do?
EDIT
It seems that I'm able to get into the user's account, I just get that error every time I su -l user.
|
I had changed a user's ID and primary group's ID, which broke things in permissions.
For a user user with a primary group of user, here's what the permissions were on the folder in question:
-rw-r----- 1 root 500 671 Oct 4 05:48 user
Since I had modified the group's id, it didn't get updated here, which broke permissions.
I simply did chown -R root:user /var/cpanel/users/user to fix the problem.
| su user fails with "grep: /var/cpanel/users/user: Permission denied" |
1,401,285,063,000 |
Is there any chattr flag that would allow me to lock a file's unix permissons, and not change them without resetting the flag? The file itself should still be modifiable, I just want to prevent ... ignorant people ... from changing the permissions to something wrong accidentally.
|
There is no such flag with Linux chattr. You can either make the file immutable or append-only (in either case, the file's permissions and ownership will be locked), or allow the owner of the file and root to change the permissions. (The immutable attribute on a directory prevents creating or removing files from it but not changing entries' metadata.)
If changing the ownership of the file is acceptable, do it, and use access control lists (or group ownership) to give whoever needs it read and write access to the file. If this is a social issue where your fellow roots can't be relied on, I don't think you'll find a satisfactory technical issue.
Disallowing the owner of a file to change permissions falls into the category of mandatory access control, which is not something unix traditionally supports. There are several MAC frameworks on Linux, and the two major ones are SELinux and AppArmor; I don't know whether they do allow what you're trying to do.
If this is a general problem, you could look into using a database for storage. You can typically give someone the permission to read and write to a table without letting them control the permissions.
A less drastic step than moving to a database would be moving the files to a different filesystem (this may or may not be feasible in your setting). You could then use symbolic links in the place where the files must exist, and hope the permission changers aren't sophisticated enough to look in the place where the real files are (perhaps that could be made read-only?).
A FUSE filesystem that mirrors file contents but changes metadata is another possibility. An existing one is bindfs, which can rewrite permissions (-o perms=…) and can ignore chmods (-o chmod-ignore).
| immutable-like flag for perms |
1,401,285,063,000 |
I'm trying ssh-ing into a rooted Android phone, but it gives me an error Permission denied (publickey)., and the log says Authentication refused: bad ownership or modes for directory, despite of the fact I have configured the permissions and ownerships carefully and correctly as shown below.
Here is the content of the file sshd_config.
/data/ssh/sshd_config
AuthorizedKeysFile /data/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
PubkeyAuthentication yes
PermitRootLogin yes
Subsystem sftp internal-sftp
pidfile /data/ssh/sshd.pid
Here is the content of the file 99sshd.
/data/local/userinit.d/99sshd
#!/system/bin/sh
umask 077
# DEBUG=1
DSA_KEY=/data/ssh/ssh_host_dsa_key
DSA_PUB_KEY=/data/ssh/ssh_host_dsa_key.pub
RSA_KEY=/data/ssh/ssh_host_rsa_key
RSA_PUB_KEY=/data/ssh/ssh_host_rsa_key.pub
AUTHORIZED_KEYS=/data/.ssh/authorized_keys
DEFAULT_AUTHORIZED_KEYS=/data/.ssh/authorized_keys
if [ ! -f $DSA_KEY ]; then
/system/bin/ssh-keygen -t dsa -f $DSA_KEY -N ""
chmod 600 /$DSA_KEY
chmod 644 $DSA_PUB_KEY
fi
if [ ! -f $RSA_KEY ]; then
/system/bin/ssh-keygen -t rsa -f $RSA_KEY -N ""
chmod 600 /$RSA_KEY
chmod 644 $RSA_PUB_KEY
fi
if [[ ! -f $AUTHORIZED_KEYS && -f $DEFAULT_AUTHORIZED_KEYS ]]; then
cat $DEFAULT_AUTHORIZED_KEYS > $AUTHORIZED_KEYS
fi
if [ "1" == "$DEBUG" ] ; then
# run sshd in debug mode and capture output to logcat
/system/bin/logwrapper /system/bin/sshd -f /data/ssh/sshd_config -D -d
else
# don't daemonize - otherwise we can't stop the sshd service
/system/bin/sshd -f /data/ssh/sshd_config -D
fi
Also I'm making sure the client pubkey is in /data/.ssh/authorized_keys.
Now, here are the permissions and ownerships of the related files and directories.
# ls -alt /data/ssh
total 56
-rw-r--r-- 1 root root 6 2023-11-16 11:56 sshd.pid
-rw-rw---- 1 root root 269 2023-11-16 10:53 sshd_config
drwxrwx--x 54 system system 4096 2023-11-16 10:47 ..
drwxr-x--- 3 root shell 4096 2023-11-16 10:13 .
-rw------- 1 root root 505 2023-11-16 10:11 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 176 2023-11-16 10:11 ssh_host_ecdsa_key.pub
-rw------- 1 root root 411 2023-11-16 10:11 ssh_host_ed25519_key
-rw-r--r-- 1 root root 96 2023-11-16 10:11 ssh_host_ed25519_key.pub
-rw-r--r-- 1 root root 604 2023-11-16 10:11 ssh_host_dsa_key.pub
-rw------- 1 root root 1381 2023-11-16 10:11 ssh_host_dsa_key
-rw-r--r-- 1 root root 568 2023-11-16 10:11 ssh_host_rsa_key.pub
-rw------- 1 root root 2602 2023-11-16 10:11 ssh_host_rsa_key
drw------- 2 root shell 4096 1974-02-26 03:43 empty
# ls -alt /data/.ssh
total 16
drwxrwx--x 54 system system 4096 2023-11-16 10:47 ..
-rw------- 1 root root 1144 2023-11-16 10:17 authorized_keys
drwx------ 2 root root 4096 2023-11-16 10:00 .
# ls -alt /data/local/userinit.d/99sshd
-rwxr-xr-x 1 root root 969 2023-11-16 10:54 /data/local/userinit.d/99sshd
Now run the sshd server.
# /data/local/userinit.d/99sshd
On a client machine, I try to connect to the phone like usual.
PS C:\Users\user> ssh [email protected]
[email protected]: Permission denied (publickey).
And fails as the error as shown above.
So I checked the log on the phone, the log says like this below.
# logcat | grep -i ssh
11-16 11:56:28.394 10599 10599 I /system/bin/sshd: Authentication refused: bad ownership or modes for directory /data
But I can't see any permissions or ownerships problem forthe related files, as I've shown above.
For a Note, I referenced:
Enabling SSH Service on CyanogenMod
SSH server on CyanogenMod Smaprtphones
The phone is:
ASUS ZenFone3 Android 10
Thanks for your help.
|
You should set /data and its subdirectories to be owned by root with permissions 0755 (rwxr-xr-x). Alternately, you can disable this permissions check by setting StrictModes to "no" in the sshd_config file on the phone.
The error message is specifically about the /data directory. According to the source code, for the authorized_keys file, sshd checks that all directories in the absolute path to the file are owned by either the user or root, and that no directory is group- or world-writable. In your case, this is the /data directory:
drwxrwx--x 54 system system 4096 2023-11-16 10:47 ..
In other words, group write access is enabled, and (until you changed it in the comments), the owner and group is "system". Both of these are unacceptable for a login attempt as "root".
| sshd: Authentication refused: bad ownership or modes for directory /data |
1,401,285,063,000 |
I want to use samba to quickly and easily share files on occasions.
I set up a smbuser to which I forbid login with
chsh -s /bin/false smbuser
I give the smbuser's password to people and I have my home dir with another username I keep safe.
Let's suppose I have this folder /home/steve/pictures/vacation/... I want to share.
With a quick chown steve:smbuser vacation I can set the following permissions
drwxr----- 35 steve smbuser 4096 Mar 28 18:58 vacation
then I set this service on my smb.conf
[shared]
comment = Used to share files quickly. Just change path down here
path = /home/steve/pictures/vacation
browsable = yes
read only = yes
create mask = 0700
directory mask = 0700
valid user = smbuser
with this configuration I cannot connect to this share.
If I
chmod -R 777 /home/steve
I can connect, but this is not the way.
How can I configure this in a better way?
|
In the end I decided to go for usershare command
Beside my /home/steve I set up a /home/public directory to which I gave 777 permission and I'm using it to receive files.
When I need to share my files with someone other I can quickly give
chgrp smbuser /home/steve/share
chmod g+r -R /home/steve/share
so that my smbuser can access it
Then I create my share with the command
net usershare add public /home/public/ . S-1-1-0:F
Note the "F" in the end to give "full access" at share DOS level
For more info reference: man smb.conf - Usershares section
This helped a lot as well
| On-the-fly SMB shares conf to quickly share files |
1,401,285,063,000 |
I want to add +x permission executable on my ISO. So I can run it directly on Linux host when clicking my CD-ROM.
I tried sudo chmod 555 tester and then burned it on ISO, but the tester only had read permission on ISO
|
As answered by Vlastimil, the ISO 9660 file system is fairly limited, and several extensions were developed to overcome its shortcomings. E.g. Joliet adds support for Unicode filenames, El Torito allows for bootable CD-ROMs and Rock Ridge enables you to use Unix file permissions on the files.
To be able to use Unix permissions on the CD-ROM files you need to add the Rock Ridge extensions when creating the disk's image. You need to check the settings for the software you are using to build the disk's filesystem, to indicate you want to add this extension (incidentally, you are likely to also find options for adding the Joliet extension for Unicode filenames, or for creating a bootable disk with El Torito).
I'm not a Linux user, but a quick search on mkisofs's manpage shows that this can be done by using the -R or -r switch (they're not equivalent, check the man page). Of course, the extension(s) must also be supported by the mount command, but this should be the case for any modern OS.
You ask specifically about CD-ROMs, but for completeness sake, I'll just add that DVDs are usually authored using the UDF file system, which has native support for Unix permissions.
| Set +x executable permission on a CD-ROM |
1,401,285,063,000 |
I want to be able to share a folder in Dolphin. Right click on a folder, then go to Share tab.
Unfortunately I see a message there: "You appear to not have sufficient permissions to manage Samba user shares":
I am on Arch Linux, if that matters. I have installed samba package and I am able to manually configure a share. But I would like to be able to do it fast from gui, just like on Windows. Also, I have seen that in other distros using KDE, this Share tab actually works.
How to fix that problem?
|
You should follow https://wiki.archlinux.org/title/Samba#Enable_Usershares.
It explains the steps. But here they are. Run:
sudo mkdir /var/lib/samba/usershares
sudo groupadd -r sambashare
sudo chown root:sambashare /var/lib/samba/usershares
sudo chmod 1770 /var/lib/samba/usershares
In /etc/samba/smb.conf add:
[global]
usershare path = /var/lib/samba/usershares
usershare max shares = 100
usershare allow guests = yes
usershare owner only = yes
Run:
sudo gpasswd sambashare -a your_username
sudo systemctl restart smb.service
sudo systemctl restart nmb.service
Log out and log back in.
Now in Share tab you can configure permissions level for your new share.
Also you can press "Show Samba status monitor" monitor and see the list of all your user shares and reconfigure them if required:
| How to share a folder in KDE Dolphin? |
1,401,285,063,000 |
My apache server puts the logfile for my project under
/var/log/apache2/foo_error.log
I set the user and group to the ones of my project (foo:www-data) and I even tried to chmod to 777 (i know that it is a risk, but it is just a local VM), but if I try to access it, then I still get Permission Denied
tail -f /var/log/apache2/foo_error.log
tail: cannot open '/var/log/apache2/foo_error.log' for reading: Permission denied
tail: no files remaining
The only solution I figured out, was to change the VHOST configuration so that the logfile is getting saved in the folder of the project. But I ask this question out of interest if it also work if the logfile is in the apache2 log folder.
|
The answer Marcus linked explains very well how directory permissions work.
To answer the "How" for your specific case - as long as the log file you want everyone accessing itself has the correct permissions to indeed allow read-only or read-write access to itself, you can create a hardlink to the file in a central location accessible by those users.
ln /var/log/apache2/foo_error.log /path/to/user_accessible_dir/foo_error.log
Note that using a symbolic link will not work as it will be affected by the original file's parent directory permissions.
If you want to better understand the difference between hard links and symbolic links (and why this works) - see this answer: https://stackoverflow.com/a/185903/17508208
| Linux - Make logfile accessible for users without permission to the folder of the logfile? [duplicate] |
1,401,285,063,000 |
How would I go about finding all files recursively that have ACLs different from what I'm searching for? For example I would like to find all files in a directory that have ACLs that are not identical to the following example:
# owner: bob
# group: bobs-group
user::rwx
user:fred:rwx
group::rw-
mask::rwx
other::r--
Using a separate search I'd like to be able to do the same for directories, but with slightly different permissions.
|
You may use find and a diff.
Save the desired reference permissions in a file, e.g. perref
$cat perref
# owner: bob
# group: bobs-group
user::rwx
user:fred:rwx
group::rw-
mask::rwx
other::r--
Do some find-magic by simply comparing the output of getfacl with the reference and negating matches. As this needs to cut the first line of getfacl output (i.e. the filename), one needs process substitution here, this must go via a shell script and proper quoting.
find -type f \
! -exec bash -c 'diff -q <(getfacl "$1" | sed 1d ) perref >/dev/null' bash '{}' \; \
-print
Or -print0 in the end, depending on the further plans. This works as diff has a 0 as exit status if files are identical.
Remove the ! for finding files with matching ACLs.
Use -type d for doing the search on directories.
| Find Files Recursively With Different ACLs |
1,401,285,063,000 |
I'm trying to understand the permissions of a unix domain socket, when using an existing file, umask changes are required as well as the dir permissions.
If I create a world readable dir as root and open a socket with netcat:
root$: mkdir /tmp/mydir
root$: chmod 777 /tmp/mydir
root$: nc -l -U /tmp/mydir/sock
Then as a non root user try to connect to aforementioned socket it fails, though the dir is world readable as per:
https://man7.org/linux/man-pages/man7/unix.7.html
In the Linux implementation, pathname sockets honor the
permissions of the directory they are in. Creation of a new
socket fails if the process does not have write and search
(execute) permission on the directory in which the socket is
created.
root$: runuser -u user1 -- nc -U /tmp/mydir/sock
nc: unix connect failed: Permission denied
Now by doing umask 0, and restarting the same socket again, it can be connected to from the non root user.
root$: umask 0
root$: nc -l -U /tmp/mydir/sock
root$: runuser -u user1 -- nc -U /tmp/mydir/sock
ping
Furthermore modifying the /tmp/mydir permissions to chmod 600 will stop the non root user from accessing the socket again.
root$: chmod 600 /tmp/mydir
root$: runuser -u user1 -- nc -U /tmp/mydir/sock
nc: unix connect failed: Permission denied
It's clear the dir permissions work as intended according to the manual, but why is umask 0 required if the parent dir has the correct permissions ? Is netcat still creating some sort of other file ?
|
You missed this in that same unix(7) manpage you're quoting from:
On Linux, connecting to a stream socket object requires write permission on that socket; sending a datagram to a datagram socket likewise
requires write permission on that socket.
Of course, you also need search(execute) permission to all the leading directories from its path, just like with any other file.
The part you're quoting refers to creating a socket, which only happens when bind(2)ing to it, which is what nc -l -U /path/to/sock does. Again, just like with creating any other file, the umask will affect the permissions of the created socket (umask == 022 => no write permission for other users => they cannot connect to the socket):
$ umask
0022
$ nc -Ul sock
^C
$ ls -l sock
srwxr-xr-x 1 xxx xxx 0 Oct 16 18:35 sock
^ ^ ^
Binding to a unix domain socket always has to create it from scratch. You cannot bind to an existing file, that will fail with EADDRINUSE. Consequently, most programs (including nc) will forcefully remove any file with the same name before binding to it:
$ echo text > file
$ strace nc -l -U file
...
socket(AF_UNIX, SOCK_STREAM, 0) = 3
unlink("file") = 0
bind(3, {sa_family=AF_UNIX, sun_path="file"}, 110) = 0
listen(3, 5) = 0
accept4(3,
NB: both snippets talk about the on-disk "socket" special file / inode, not about the inode representing the active socket object (which appears in /proc/<pid>/fd, /proc/net/unix, etc):
$ nc -lU sock &
[1] 4424
$ ls -li sock
20983212 srwxr-xr-x 1 xxx xxx 0 Oct 17 18:01 sock
^^^^^^^^
$ ls -li /proc/4424/fd
total 0
43825 lrwx------ 1 xxx xxx 64 Oct 17 18:02 0 -> /dev/pts/4
43826 lrwx------ 1 xxx xxx 64 Oct 17 18:02 1 -> /dev/pts/4
43827 lrwx------ 1 xxx xxx 64 Oct 17 18:02 2 -> /dev/pts/4
43828 lrwx------ 1 xxx xxx 64 Oct 17 18:02 3 -> socket:[46378]
^^^^^
$ grep 46378 /proc/net/unix
00000000ee8c0faa: 00000002 00000000 00010000 0001 01 46378 sock
| unix domain socket permissions and umask integration between root and non root users |
1,401,285,063,000 |
While trying to make my tarballs reproducible, i followed this guide.
As a side-effect I noticed that I can easily create a tar-file that, when unpacked will change the permissions of the current working directory (where i extract my files into).
Like so:
$ rm -rf /tmp/user
$ mkdir -p /tmp/user/test
$ touch /tmp/user/test/README.txt
$ ls -lhan /tmp/user/ /tmp/user/test/README.txt
-rw-r--r-- 1 11002 11002 0 Sep 15 10:31 /tmp/user/test/README.txt
/tmp/user/:
total 32K
drwxr-xr-x 3 11002 11002 4.0K Sep 15 10:31 .
drwxrwxrwt 23 0 0 20K Sep 15 10:31 ..
drwxr-xr-x 2 11002 11002 4.0K Sep 15 10:31 test
$ cd /tmp/user/test
$ tar --numeric-owner --owner=0 --group=0 --mode="go-rwx,u-w" --transform 's|\./|foobar/|' \
-czf ../foobar.tgz .
$ tar tvf ../foobar.tgz
dr-x------ 0/0 0 2021-09-15 10:25 ./
-r-------- 0/0 0 2021-09-15 10:25 foobar/README.txt
$ cd /tmp/user/
$ tar xvf foobar.tgz
$ ls -lhan
total 40K
dr-x------ 4 11002 11002 4.0K Sep 15 10:31 .
drwxrwxrwt 23 0 0 20K Sep 15 10:31 ..
drwxr-xr-x 2 11002 11002 4.0K Sep 15 10:33 foobar
-rw-r--r-- 1 11002 11002 143 Sep 15 10:32 foobar.tgz
drwxr-xr-x 2 11002 11002 4.0K Sep 15 10:31 test
$ rm foobar.tgz
rm: cannot remove 'foobar.tgz': Permission denied
$
So what happens is:
the tarfile contains a ./ entry that has permissions 0500 (aka r-x------)
when extracting the tarfile it will also extract the ./ direcctory (which happens to be the current directory) and sets its permissions to the ones found in the archive
after the operation, the user can no longer remove files from this directory and others can no longer do anything with it.
this comes as a big surprise. it might render the system "unusable" for the user (e.g. effectively running chmod a-rwx on the users home directory).
of course it is easy enough to restore the permissions - if you have heard of chmod before (something the typical Ubuntu user might not) and you remember the prior permissions (something I cannot say for myself and an arbitrary directory where i would extract a tarball)
so my question is twofold:
how can i prevent tar --extract to change the permissions of my current working directory while still preserving the permissions of the other files in the archive?
how can I prevent tar --create from actually creating such an archive (so that it also works for people that don't know the answer to the first question), while still prepending a known path-component)?
edit
i probably already found parts of the answer to my 2nd question.
Changing the path mangling to --transform 's|^\.|foobar|' will also mangle the ./ entry into foobar/, which will then get the permissions declared in the archive (and leave my current working directory alone).
I wonder though why --transform 's|\./|foobar/|' will not mangle ./ (as it seems this matches the \./ regex nicely.
|
As far as I’m aware, the only way to prevent changes to .’s metadata when extracting a tarball is to skip existing files, with the --skip-old-files option available in GNU tar. This covers more than . and will result in any existing files being kept as-is, instead of being overwritten by the version in the tarball.
I’m not sure why your --transform fails. The recommended approach to prepend a path when extracting is to “replace” the start anchor with the desired directory, e.g. tar --transform 's,^,foobar/,' .... To avoid messing up symlinks, a suffix can be added, e.g. tar --transform 's,^,foobar/,S' which will not apply the transformation to symlink targets.
| how to prevent 'tar extract' from changing the permssions for current directory? |
1,401,285,063,000 |
When I edit a file, and then want to undo my changes, I use
git checkout -- file.txt
the problem is that git does not keep the file permissions of the existing file. file.txt has permissions 644, but after git checkout it has 600 (which I think comes from my umask)
I know git does not store file permissions, and I am not expecting to remember permissions when creating new file.
But in this case the file exists.Why can't git keep the permissions as they are?
Could this be solved with some ugly hack (some hook) ?
|
When Git checks out files, it by default uses the umask of the file on the system, setting the executable bit if it's a directory or it's marked as an executable file. That's because Git removes and re-creates the file, so it doesn't preserve the permissions of the existing file.
This is actually by design, because there's an option, core.sharedRepository, that lets you configure the permissions of files to be checked out. By default, it is set to umask, which means to use your umask. If you want different behavior in your repository, you can set it differently, such as to 0644, which will use that value.
It is possible to use a post-checkout hook to change the permissions back if you want, although this may not work in all cases.
| git checkout -- file changes permissions for existing file |
1,401,285,063,000 |
I inherited a Debian Server I think the former sysadmin used to manage with webmin. It is standalone, so security groups should be Linux default config, no LDAP or AD intergration or anything advanced like that.
When I run "getent group" I see user accounts that do not exist in "getent passwd." I am fairly confident these are just users that existed but were deleted in the past. Is this normal for those accounts to remain in the groups, and if so is there a easy way to clean this up?
Thanks.
Thanks,
Josh
|
The command grpck from the passwd package would take care of cleaning them up, among other things. From its man page:
... verifies the integrity of the groups information. It checks that all entries in /etc/group and /etc/gshadow have the proper format and contain valid data. The user is prompted to delete entries that are improperly formatted or which have other uncorrectable errors.
Checks are made to verify that each entry has:
the correct number of fields
a unique and valid group name
a valid group identifier (/etc/group only)
a valid list of members and administrators
a corresponding entry in the /etc/gshadow file (respectively /etc/group for the gshadow checks)
| getent group shows nonexistent users |
1,401,285,063,000 |
I've created this unit for systemd (v241) on the file /etc/systemd/user/foo.service
[Unit]
Description=Foo
After=mysqld.service
[Service]
Type=simple
Restart=always
RestartSec=1
StandardOutput=append:/home/pioz/foo/logs/backend.log
StandardError=append:/home/pioz/foo/logs/backend.log
WorkingDirectory=/home/pioz/foo
ExecStart=/home/pioz/foo/backend/current/foo
[Install]
WantedBy=multi-user.target
When I start the service with systemd --user start foo (without sudo) I get the following error:
foo.service: Failed to set up standard output: Permission denied
If I comment on the options StandardOutput and StandardError on the unit file, the service starts correctly.
I run the service as user pioz, a normal Linux user. The file /home/pioz/foo/logs/backend.log are writable from the pioz user, in fact I can edit the file with nano.
How can I solve this permission denied error?
|
If you're going to run the service as a regular user, move the .service file in their $HOME/.config/systemd/user directory (check permissions, of course). Then run the service like this:
systemctl --user start foo.service
| systemd --user Failed to set up standard output: Permission denied |
1,591,402,329,000 |
While learning how to build and install a custom kernel (for kernel hacking), I came across a contradictory statement.
In this StackExchange answer, the author states:
in the following instructions, paths inside the source tree take the form [src]/whatever, where [src] is the directory you installed the source into, e.g. /usr/src/linux-3.13.3. You probably want to do this stuff su root as the source tree should remain secure in terms of write permissions (it should be owned by root).
While in the reference book, that he mentioned: Linux Kernel in a nutshell,
Greg Kroah-Hartman says:
This warning is the most important thing to remember while working through the steps in this book. Everything in this book — downloading the kernel source code,uncompressing it, configuring the kernel, and building it — should be done as a normal user on the machine. Only the two or three commands it takes to install a new kernel should be done as the superuser (root).
and
The kernel source code should also never be placed in the/usr/src/linux/directory, as that is the location of the kernel that the system libraries were built against, not your new custom kernel. Do not do any kernel development under the /usr/src/directory tree at all, but only in a local user directory where nothing bad can happen to the system.
Both sources are quite old, what is the correct approach to this nowadays?
|
/usr is the wrong place for anything "custom":
man hier:
/usr/src
Source files for different parts of the system, included with some packages for reference purposes. Don't work
here with your own projects, as files below /usr should be read-only except when installing software (optional).
/usr/src/linux
This was the traditional place for the kernel source. Some distributions put here the source for the default
kernel they ship. You should probably use another directory when building your own kernel.
man file-hierarchy:
/usr/
Vendor-supplied operating system resources. Usually read-only, but this is not required. Possibly shared between
multiple hosts. This directory should not be modified by the administrator, except when installing or removing
vendor-supplied packages.
/usr/include was relying on /usr/src/linux before:
/usr/include/linux
This contains information which may change from system release to system release and used to be a symbolic link
to /usr/src/linux/include/linux to get at operating-system-specific information.
So the kernel sources only belong in /usr/src to be referenced, not modified.
The Documentation/admin-guide/README.rst shows the O= option so you can turn a build into a read-only affair in /usr/src/linux-VERSION
cd /usr/src/linux-4.X
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
Like that also the .config file is created under /home.
| Is /usr/src a valid location for a custom kernel? |
1,591,402,329,000 |
We're using samba Acitve Directory (AD) Version 4.3.11-Ubuntu with Windows Active Directory Users and Computers MMC console. The file server (attached to the domain) is Ubuntu 14.04.6 LTS. In this case, the user is connecting via NFS.
When the user makes a directory (mkdir ./testdir) or creates a file (touch testfile) the directory and file both show up as owned by the group domain users instead of the group listed in MS AD Users and Computers as the primary group (in this case "students".)
Is there a way to ensure new files/directories as created with the ownership of the Primary Group?
|
Yes, but not with Samba 4.3.x, you will need to upgrade to 18.04, which will get you to at least 4.7.6 and you can then use (along with the winbindd 'ad' backend) this line in smb.conf:
idmap config SAMDOM:unix_primary_group = yes
| SAMBA AD new files group is "domain users" not the Primary Group |
1,591,402,329,000 |
I wonder if it's possible to make files creatable, but not writable or removable. So that every file is created with r--r--r-- permissions.
My current smb.conf:
[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = ubuntu
security = user
map to guest = bad user
dns proxy = no
#=== Share Definitions ===
[Anonymous]
path = /samba/anon
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody
create mask = 0444
force create mode = 0444
directory mask = 0444
force directory mode = 0444
I'm stuck with /samba/anon permissions being set to drw-rw-rw-. If I remove the w, users can't create files anymore, with it - files are removable. Can this dilemma be solved?
|
You can try with the following (I cannot verify now it works but it should):
[Anonymous]
path = /samba/anon
browsable =yes
writable = yes
guest ok = yes
read only = no
force user = nobody
create mask = 0644
force create mode = 0644
directory mask = 3775
force directory mode = 3775
inherit owner = yes
Then set permissions on the share main directory (where sambaadm is some linux user different to nobody):
chown -R sambaadm:nogroup /samba/anon
find /samba/anon -type d | xargs chmod 3775
find /samba/anon -not -type d | xargs chmod 0644
This utilizes sticky bit on the directories to make files deletable only by owner. With "inherit owner" You force the user to be always sambaadm so deletes not possible for the nobody user. Also writes to files only allowed for sambaadm whereas the nobody users can write to the directories with their nogroup groupmembership.
| Configuring Samba permissions |
1,591,402,329,000 |
So as root, when I try to cat a file without the read permission, I can still see what's in it, which seems kind of strange, because as root I cannot write to a file without the w permission (it opens as read-only) and I cannot execute a file without the x permission.
Am I doing something wrong?
[root@aaaaaa enc]# ll logsuper
--w-------. 1 root root 3268 Apr 19 13:26 logsuper
[root@aaaaaa enc]# head logsuper
Done at Fri Apr 19 12:22:02 UTC 2019
Also can't execute file without the x permission as root:
[root@aaaaaa enc]# ll test1
----------. 1 root root 25 Apr 19 13:40 test1
[root@aaaaaa enc]# cat test1
#!/bin/bash
echo "${1}"
[root@aaaaaa enc]# ./test1 asdfasdasgasga
bash: ./test1: Permission denied
|
The root can do anything and permission tests are bypassed for it.
Read also about setuid.
Since a program -even head or a shell, even when run by root (whose uid is 0 by definition)- uses system calls (listed in syscalls(2)...)
See also path_resolution(7) and capabilities(7) and credentials(7).
Together they explain when open(2) -done by the process running /usr/bin/head - will fail. BTW, read(2) does not check permissions.
Notice that execution of some executable is done by execve(2) which documents when it could fail. Your shell is doing many fork(2) and execve calls.
A good Unix programming book, such as the old ALP, has several chapters explaining all that. Your shell is just another program (read also about the Unix philosophy) and you could write a shell in C (or study the source code of existing free software shell programs, e.g. of GNU bash).
| Can still cat/tail/head/etc. a file without the read permission |
1,591,402,329,000 |
I need to give permission to a user to start, stop and restart Rstudio's shiny-server.
Right now, I have been managing the service upon this user's request with sudo service restart shiny-server, but now I want the user to manage this.
My first approach to this problem is to edit the /etc/sudoers. But I realized I have no idea what the full path of shiny-server is, so I have no idea what to put in the /etc/sudoers file. I would have hoped to find it in /etc/init.d/, but that isn't the case.
Does anyone have experience with this or a work-around?
I'm currently running Ubuntu 16.04.5 LTS (Xenial Xerus) on this server.
The version of R is 3.4.1 and it was compiled from source.
|
You probably don't need the filepath for shiny-server.
You should be able to give the user the required permissions by adding the following line to your /etc/sudoers file:
username ALL=(root) service restart shiny-server, service stop shiny-server, service start shiny-server
After adding that line, the other user should be able to run sudo service restart shiny-server (as well as start/stop. If you're intent on finding the init script locations, the normal locations to look are:
/etc/init
/etc/init.d
/etc/init/rc-sysinit.conf
/etc/default
(found via this question)
| Give a user permissions to start, stop or restart shiny-server |
1,591,402,329,000 |
Is there a way (with acl's) to protect the contents of a folder? Users should create files inside a folder but not overwrite/edit/delete them. Is this possible?
|
One might use inotifywait to watch the directory and make changes, such as changing ownership of each new file copied into the directory. In a Debian-based distribution, install the software as follows: apt-get install inotify-tools.
Create a script, perhaps /usr/local/sbin/inbox.sh, as follows.
#!/usr/bin/env bash
inotifywait -m -e create "/path/to/directory" |
while read path event file; do
if [ "$event" = "CREATE" ]; then
chown root:root "$path$file"
fi
done
Give the script permission to execute (chmod 0700 /usr/local/sbin/inbox.sh). Then run it at boot time from, say, /etc/rc.local or whichever RC file is appropriate: /usr/local/sbin/inbox.sh &.
According to the manual, -m monitors indefinitely, and -e watches for a specific event. Within the while loop, it could be possible to receive an event such as CREATE,ISDIR, which indicates the creation of a directory, of course. Directories are not the target of the question; thus the if statement contains a command to respond only to new files, which are represented with the event, CREATE. The path variable from inotifywait has a trailing slash character, so $path and $file can be concatenated without specifying a slash between the two.
| Protect overwriting folder content |
1,591,402,329,000 |
For testing purposes a systemd service file is meant to execute a simple bash script. I want the service to be started by a "system" user. The bash script is owned by this system user and has granted execution permission.
The Service file is simply:
[Unit]
Description=Come one step closer
After=network-online.target
Requires=network-online.target
[Service]
User=test1
Group=test1
Type=simple
ExecStart=/usr/bin/bash /absolute/path/to/test.sh
[Install]
WantedBy=multi-user.target
The test.sh script should simply give out a message to journalctl - it is just for testing.
I reloaded the systemd unit files with:
$ sudo systemctl daemon-reload
I started the service with:
$ sudo systemctl start tester.service
The output of systemctl status tester.service yields, that there is no permission for the bash execution.
I added the "system" user test1 like that to the system:
$ sudo useradd -r -s /usr/bin/bash test1 -U
What do I need to do for user test1 to get permission to start the service. I cannot test the bash script with user test1, because as test1 being a system user I cannot log in as test1.
|
As established on the comments, the problem is with permissions of the directories above /absolute/path/to/test.sh, in which a non-root user needs to have "execute" (x) permissions in order to be able to access the script.
This can be diagnosed by looking at the mode of each of the parent directories, for example using a command such as:
ls -ld / /absolute /absolute/path /absolute/path/to /absolute/path/to/test.sh
And checking whether "test1" user would have execute permissions to all directories, in addition to read permissions to the test.sh script itself.
| Start systemd service with a "system" user to execute a bash script |
1,591,402,329,000 |
I'm not sure if this would be the right place to ask this question.
I've created a sample website using metaexploitable OS, and since this is a terminal-based OS I've been having trouble coding my html site with the vi editor, I was wondering if anyone know how to can access my root directory (and have control, adding files into the root directory) for a different machine.
Right now I'm running metaexploit on VirtualBox and I'm able to access the root directory and the files from my host machine (Windows 10)
All my files for the server are located in the directory /var/www, and when I do http://server_ip_addr, I get to the directory folder which states index on it, I see a few files that I've created etc.
I've also noticed that there is a myPHPAdmin file which when I went to that section of the site, http://my_ip_addr:80/myPHPAdmin
I required a username and password. Would I need access to this in order to be able to upload files into my server directory? If so does anyone know the default username and password? I did some research and from my understanding (might be completely off) that I would need to install a database in order to even log into that section.
So if anyone has any ideas on what I can do in order to load files into that directory using my host machine, or if there is no means to do that, if anyone could recommend a good text editor where editing isn't such a drag, I would greatly appreciate it!
I'm running Apache/2.2.8 (Ubuntu) DAV/2 Server
Thank you!
|
The PHPMyAdmin login credentials should be these:
User: root
Password: (leave it blank)
Source: Metasploitable 3 Wiki - Vulnerabilities
You should not need to install anything (less yet "a database [server]") to access the system.
If you have a relative lack of experience using vi, I would recommend you nano, which is a bit more friendly.
| Metasploitable server |
1,591,402,329,000 |
Here's the situation -
I have a 1TB drive mounted at /data.
There are multiple local users on the desktop. All of them are in the localusers group
I have a virtualbox VM with a 50 GB VDI dsik stored at /data/common/vms
I would like the virtualbox VM to be available to all members of the localusers group.
What I've done so far:
As the primary user, create the VM
Moved the vbox machine folder to /data/common/vbox [so if the machine is Win10Pro, then I have the folder at /data/common/vbox/Win10Pro]
Group Perms - group of the folder to localusers and chmod -R g+rw /data/common/vbox /data/common/vms
Copied over ~/.Virtualbox/Virtualbox.xml and adjusted Default machine folder and machine entry to point to /home/user/VirtualBox VMs.
ln -sf /data/common/vbox/Win10Pro ~/VirtualBox VMs/Win10Pro for each user
The problem
This only works once... If as user X I open virtualbox and launch the machine, then the permissions on the /data/common/Win10Pro/* file(s) revert to rw only for the user after the Virtualbox GUI exits.
PS: Earlier I used toe have the disk formatted as exfat and was able to achieve a shared disk/vm using the uid and gid masks but that doesn't work for ext4.
|
for those landing here with a similar predicament, I posted the question on Reddit and was quickly pointed in the right direction
basically:
Set the setgid bit on the shared folder /data/common
Set default acl to rwx for user and group like so: setfacl -d -m u::rwx,g::rwx,o::r-x /data/common
A more detailed walkthrough's available here
http://brunogirin.blogspot.com/2010/03/shared-folders-in-ubuntu-with-setgid.html
The article's from 2010 - so the only differences were that I did not have to install any packages or set mount options - ACLs were on by default
| Share folder/files between multiple users on ext4 disk |
1,591,402,329,000 |
There's something strange on the Raspbian linux about file permissions:
Logging in with the default pi user end executing
sudo touch new_file
and then
ls -l new_file
yields
-rw-r--r-- 1 root root 0 May 28 09:33 new_file
but then,without sudo I can delete the file with
rm new_file
Even if it prompts the following
rm: remove write-protected regular empty file 'new_file'? y
Pressing y the file is deleted.How is that possible?
|
The reason you can delete the file new_file despite not being its owner, is because you have write permissions to the directory that holds new_file (this directory is probably pi's home directory.)
You can check this with stat .
It's also worth mentioning that if the directory has the sticky bit enabled (for example, /tmp), then having write permissions in the directory isn't sufficient to allow you to delete contained files.
| Raspbian filesystem user permissions |
1,591,402,329,000 |
I've been wondering if there is a good reason why a regular user can't create their own group. It would make sense for the file owner to be able to set up a group and manage file permissions. For instance a user could allow only their close friends on the system to read their home folder, so they set up their own group to manage file permissions to files for which they have ownership.
Is there a security concern I'm not seeing here? I don't see why the sysadm has to maintain all groups on the system.
|
Groups are a system-wide resource that are stored in a single file owned by root. The current group format makes no distinction between "user" and "system" groups other than GID range, and even if it did, it has no way of granting access to portions of the file to different people. Because of this, you would have to come up with a new system to allow non-administrators to add and remove groups without giving full access via sudo and equivalents. There apparently hasn't been enough demand for this feature (likely because Unix installations were originally institutional), but there was enough demand to implement a related feature.
You can delegate a user to be able to modify group membership using gpasswd. If you give a user administrative control over a group, they can then add or remove members without having to have root access (by default, there is no group administrator, so only root can make changes.) Given the following (as root):
# groupadd newgroup
# gpasswd -A owner -M member1,member2 newgroup
The user owner can now modify the group newgroup without having to get any other permissions:
$ gpasswd -a member3 newgroup
Adding user member3 to group newgroup
(You'll notice that the group administrator doesn't actually have to be a member.)
| Why can't regular users create and manage user groups? |
1,591,402,329,000 |
When trying to PUT an index.html file in the root of an already existing folder, nginx fails with:
[crit] 1181#0: *1 rename() "/opt/spool/nginx/client_temp/1/0000000001"
to "/opt/share/www/domain.tld/index.html-3hlCQ9iE" failed (13:
Permission denied), client: 1.2.3.9, server: host.domain.tld, request:
"PUT /www/domain.tld/index.html-3hlCQ9iE HTTP/1.1", host: "172.21.2.2"
Environment
Using nginx-extras 1.13.6-1 from entware-3x repo.
running on Padavan firmware.
$ grep www-rw /etc/passwd
www-rw:x:1000:1001:Linux User,,,:/opt/share/www:/bin/sh
$ grep www-w /etc/group
www-w:x:1001:
$ ls -l /opt/share/www
drw-rw-r-- 2 www-rw www-w 4096 Feb 9 13:51 domain.tld
$ ls -al /opt/share/www/domain.tld
drw-rw-r-- 2 www-rw www-w 4096 Feb 9 13:51 .
drwxr-xr-x 4 www-rw www-w 4096 Feb 9 13:51 ..
$ ls -l /opt/spool/nginx
drwxrwxrwx 7 www-rw root 4096 Feb 9 22:46 client_temp
$ ls -l /opt/spool/nginx/client_temp
drwx------ 2 www-rw www-w 4096 Feb 9 22:28 5
Client: Cyberduck/6.3.3.27341
Client-user: www-rw
Content of nginx.conf
user www-rw www-w;
server {
location /www {
root /opt/share;
client_body_temp_path /opt/spool/nginx/client_temp 1;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
# allow creating directories
create_full_put_path on;
dav_access user:rw group:r all:r;
autoindex on;
}
}
Regression
user nobody nogroup;
dav_access user:rw group:r all:r;
#autoindex ...
Client-user: admin
What should I fix (in the permissions?) to resolve the Nginx dav permission denied errors?
|
$ ls -l /opt/share/www
drw-rw-r-- 2 www-rw www-w 4096 Feb 9 13:51 domain.tld
Not specifically tested, but... add x (execute) permissions there.
That is:
chmod 775 /opt/share/www/domain.tld
or
chmod 755 /opt/share/www/domain.tld
x (execute permission) on a directory is needed for some things that you might naively think should only need w (write permissions).
Source: Francis Daly on Nginx mailing list 2018 February
| How to resolve Nginx dav PUT request failed on rename() with (13: Permission denied)? |
1,591,402,329,000 |
I suspected meld needed them to be also writable. However, it does say Could not read file (notice "read"); plus then the implication would be that they are writable for root, because there was no such error for root.
~$ diff <(echo foo) <(echo bar)
1c1
< foo
---
> bar
~$ meld <(echo foo) <(echo bar) # not working, see comment below
~$ sudo -s
~# meld <(echo foo) <(echo bar) # works just fine
The first one returns Could not read file and [Errno 2] No such file or directory: '/dev/fd/63'.
What do you suspect is the reason for this behavior?
Unprivileged user above, root below.
|
This happens when a Meld window is already open. In that case, running meld again tries to use the existing Meld process; but that process can’t access the /dev/fd files which are used for the substitution...
There doesn’t seem to be an option to force Meld to use the “new” process, ignoring all others.
| Possible reasons why meld cannot access /dev/fd/* when run as unprivileged user? |
1,591,402,329,000 |
I'm using the maven antrun plugin to execute an sshexec command in order to copy a tar and extract it to a target directory on a remote server.
The command I run to extract it is:
/bin/sh -c 'tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;'
This used to work fine until the owner of the target directory changed to a new user that is setup as nologin. I'm trying to figure out how to run this command as the new user.
I've tried to model it after Basil A's answer
/bin/su -s /bin/sh -c 'tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;' ${newUser}
But it prompts me for a password, which isn't going to work since its a nologin user.
Also, I'm not an expert on Linux but if I also just try to simply run this command from my home directory as the old user (which has sudo access), this fails
sudo -u ${newUser} tar -vxzf /path/to/${artifact}.tar.gz -C path/to/target/directory;
However, if I cd to the target directory and run that same exact command as the old user it works. I'm guessing maybe if I understand this difference in behavior it will help me get the answer?
|
It doesn't sound to me like the issue here has anything to do with the new user being a system user or a no-login user. It sounds like the mostly likely explanation for what happened is that, since the owner of the target directory changed, there now isn't a user that has read permissions for the source directory and write permissions to the target directory.
Since you have sudo privileges on the host in question, you have a lot of options for how to resolve this.
You could give your original user write permissions to the target directory and run your tar command as that user.
You could give the new no-login user read permissions to the source directory and run your tar command as that user.
You could run the tar command with sudo and then set the ownership to be whatever you want it to be afterwards.
For example, something like the following should work:
sudo tar -vxzf /path/to/${artifact}.tar.gz -C /path/to/target/directory
sudo chown -R "${newUser}:${newUser}" /path/to/target/directory
If you want to use a little more finesse and avoid having to run this as root, then you should update your question to include the permissions and ownership information for the directories in question as well as the group memberships of the relevant user accounts.
| run command as different nologin user |
1,591,402,329,000 |
On the Linux machine LinuxClient I'm trying to mount an SMB share backups located on the Unix machine Server.
I want to provide separate directories within backups for different purposes, and I want to set restrictive permissions on those subdirectories (access only for owner):
backups (accessible to all users in group backups)
backups/LinuxClient (accessible only to _LinuxUser_)
backups/OtherClient (accessible only to _OtherUser_)
Server and LinuxClient have separate user accounts with different, but overlapping UIDs. Out of necessity, LinuxUser has different UIDs on LinuxClient and Server.
To resolve this, I have created network-wide groups net-backups and net-LinuxUser with GIDs that are the same on all machines, and added LinuxUser to both groups on LinuxClient and on Server.
I have set the following permissions on the directories:
root@server:/ # ls -la backups
total 27
drwxr-x--- 5 root net-backups 6 Aug 9 09:13 .
drwxr-xr-x 11 root root 11 Aug 3 17:56 ..
drwxrwx--- 2 LinuxUser net-LinuxUser 2 Aug 9 09:13 LinuxClient
I have successfully mounted backups on LinuxClient.
Why am I still getting Permission denied when trying to cd into /mnt/backups as LinuxUser, but not as root?
|
D'uh. Turns out reloading the user session did the trick.
group and id weren't showing the new groups either until I logged in again.
| Mounted SMB shares: permission troubles with UID mismatch between client and server [closed] |
1,591,402,329,000 |
I've had a Fedora 25 installation for a day or two in a VM, the Cinnamon spin.
In my last session I ran a few programs, installed Wine, but didn't do a dnf update, edit my .bash_profile, or make any significant changes that I can recall.
Suddenly, when I attempt to log in, the screen reverts to a cursor on black for about 0.5 seconds (seeming to crash) then the login screen comes back.
I can log in successfully as root, using the same UI, so it seems isolated to my user account.
If I Ctrl+Alt+F5, I can login successfully, but I see an odd error:
Last login: Wed Mar 1 14:02:58 on tty5
-- craig: /home/craig: change directory failed: Permission denied
Logging in with home = "/".
[craig@localhost /]$ cd
[craig@localhost ~]$ ls -la ~ | grep "\.$"
drwx------. 26 craig craig 4096 Mar 1 13:17 .
drwxr-xr-x. 26 root root 4096 Feb 28 07:58 ..
[craig@localhost ~]$
(Typed the above by hand so excuse any typos.)
I tried changing my home directory permissions to 755 but the result is the same. (Both for graphical and tty login.)
I've done a bit of research, I do not have an ~/.XAuthority file. I do have .xsession-errors, but it doesn't seem to be updated when my login attempts fail. (It's a couple hours old.)
fpaste link for .xsession-errors
I have general working knowledge of Unix, but not a lot of experience with Fedora/Cinnamon. Where should I look next?
Update:
SELinux Alert Browser shows the below options:
Related AVCs from ausearch -m AVC are:
type=AVC msg=audit(1488394978.226:257): avc: denied { search } for pid=1426 comm="login" name="craig" dev="dm-2" ino=2621441 scontext=system_u:system_r:local_login_t:s0-s0:c0.c1023 tcontext=system_u:object_r:unlabeled_t:s0 tclass=dir permissive=0
|
As proposed in the SELinux Alert browser
/sbin/restorecon -v /home/craig
should resolve the problems.
What was wrong?
From the AVC:
type=AVC msg=audit(1488394978.226:257): avc: denied { search } for pid=1426 comm="login" name="craig" dev="dm-2" ino=2621441 scontext=system_u:system_r:local_login_t:s0-s0:c0.c1023 tcontext=system_u:object_r:unlabeled_t:s0 tclass=dir permissive=0
You can read that your home directory (name="craig") had a wrong label (unlabeled_t), instead of the expected type (user_home_dir_t from the screenshot). SELinux has is MAC (Mandatory Access Control) and the login was trying to do something that was not allowed by the policy, it was forbidden.
It was probably caused by some manipulation of your home directory.
| Fedora 25 Cinnamon stuck in graphical login loop, tty login successful |
1,591,402,329,000 |
After migrating a maildir network share (CIFS) to a new storage server, I started having problems with file permissions (users unable to delete old mail). My IMAP service is Dovecot but we can identify the problem at a lower level than that.
As root I can navigate to a mail directory exhibiting this problem both on the server hosting the files and the server where they're mounted (hereafter referred as 'client'), and experience/observe the following behavior:
ls shows the same file listing and permissions on both machines.
Permissions did not match exactly since the migration, but no permission changes affect the behavior. (All future operations are performed against files with permissions -rw-rw---- 1 mail mail.)
Performing operations as mail instead of root also has no effect.
Attempting permission changes such as chmod g-rw *:
on the server works fine
on the client works fine for files created since the migration
on the client produces this error for pre-migration files:
chmod: changing permissions of '1479603582.M874812P11259.Pantheon,S=84750,W=85933:2,Sa': Invalid argument
Attempting to read the file:
on the server works fine
on the client filename autocompletes and vim reports Permission Denied
Looking for any ACLs that might be affecting older files, I get this output on the server:
root@<storage-server>:/<path-to-share>/<site>/<user>/folders/cur# getfacl <filename>
# file: <filename>
# owner: mail
# group: mail
user::rw-
group::rw-
other::---
getfattr outputs nothing.
The storage server was previously an abandonware solaris+debian based OS (Nexenta) serving with CIFS on a ZFS storage pool. Now it is Ubuntu 16.04, again serving with CIFS on a ZFS storage pool. In all cases ACLs are/were supported but not used anywhere.
My Samba share config:
[Maildir]
path = /<path-to-share>
browseable = no
guest ok = no
valid users = mail
writable = yes
create mode = 0660
directory mode = 0770
which is mounted as //<host>/Maildir /var/mail cifs auto,credentials=/root/.smb_mail,user,rw,exec 0 0. All zfs properties are at defaults for this filesystem and its parents.
I've tried removing create mode/directory mode, and adding @mail to valid users, all to no effect.
How else could my permissions be going wrong?
Update:
I tried switching to an NFS share instead, and the problem persists. I tried copying the maildir contents to a new location (in a different new filesystem) with cp -r and chown -r mail:mail, and again it persists, while served from a completely different path.
Finally, I tried mv somefile backup && rm somefile && cat backup > somefile && chown mail:mail somefile, and attempting to read that file still fails with Permission Denied.
I'm at a loss as to how operations on specific files can be blocked in a manner that is independent of the sharing mechanism, logical location, unix permissions/ownership, and even any form of file metadata.
Update 2:
I had another go at switching to an NFS share and this time the permission issue went away. However I do not want to switch to NFS as it is causing other issues particularly for bootup. The issue is definitely with samba, but clearing all operational data (various .tdb and .dat files, etc.) also did not help.
Update 3:
The problem has been narrowed down to filenames with colons in them. Renaming a file to remove the colon renders it readable in the client, and renaming to an arbitrary, original name with a colon renders it unreadable. It appears Dovecot is renaming files over time to track some information and that adds a colon which eventually renders all mail unreadable/unwriteable, but this would have previously been the case as well.
Some additional observations: creating and then reading a file with a colon on the client works (and the colon appears as a double-quote on the server). Incidentally this is how we'd be getting filenames with colons in the first place... Newer files appear to have 2 colons, but on the server show as having one double quote and one colon.
It's starting to look like some kind of encoding issue - especially odd since these two systems are homogenous for the first time.
|
Samba does not allow colons in filenames and uses character remapping (to quotes) to support them in a presumably windows-friendly way. At some point the handling of this was different, resulting in actual colons in filenames server-side. That, or I may at some point have actually copied the files via the share. (Unlikely, as everything was maintained with zfs incremental sends during the transition.) Additionally, when using an NFS server, Dovecot started applying renames that broke Samba for newer content as well.
Since the colons are part of disposable metadata embedded in the filename which gets regenerated if incorrect, I used a script to strip all real colons from the share: find "$@" -name '*:*' -exec rename 's/://g' {} +.
(I tried being a bit more clever but the filename only appears to have a double quote in place of colon, and working out the precise translation is of minimal value for the effort, especially after 12 hours of head banging.)
After this all files became readable again, and the only real data loss was having to mark a bunch of emails read again. I only hope this fix is a one-time affair.
| Mysterious Samba permission failures after service migration |
1,591,402,329,000 |
I have a directory that goes like this:
drwxrwxrwx 6 www-data www-data 4096 Jun 8 10:21 ./
drwxr-xr-x 31 user1 user1 4096 Jun 8 10:40 ../
lrwxrwxrwx 1 www-data www-data 66 Jun 8 10:21 archive -> /media/user1/7f62b5e4-4fe7-43c2-b0d0-8dad6e5a2381/archive/
I try to create a file with touch in the symbolic link with the user www-data. I get this error:
$ sudo -u www-data touch archive/myfile
touch: cannot touch ‘archive/myfile’: Permission denied
The root directory and the archive directory are chmod 777.
But this works correctly
$ touch archive/myfile
What am I missing?
|
I fixed the probleme by mounting the hard disk pointed by the symbolic link. In fact, media/ is the path set by default so you need to mount the disk to set a valid path. Here is a link were you can find how to automatically mount a hard disk : InstallingANewHardDrive
| Can't create a file through symbolic link |
1,591,402,329,000 |
I have on ext4 disc the following file:
-r--r--r-- 1 root root 61440 20. pro 15.30 ldlinux.sys
But rm, chmod and mv says permission denied even for root. Any ideas what could be the problem?
FYI, it is file in boot sector of distro slax, but it is not used for booting. I just extracted the installation archive and I want to remove it.
|
You have probably mistake somewhere. Either:
You're trying to remove the file as unprivileged user,
The file has file attributes: see them with lsattr ldlinux.sys,
The directory you're trying to remove file from has file attributes, see them: lsattr . (in directory containing ldlinux.sys).
Other conditions may apply, for example readonly filesystem, but they usually generate errors other than permission denied.
Superuser can override any permission checks in the kernel, and file mode does not matter.
| Root cannot remove file on ext4 |
1,461,478,116,000 |
As the main admin of a server, I want to make it so that users can't see each others home folders. (so I chmod 750 the home folder which includes me, so I can see mine but can't see other people's).
I realise I can 'su' to change in to the users if I need to see in their folders, but I am presuming that root would be able to move in to that folder and see the contents, but obviously I can't 'sudo cd' or 'sudo ls'.
So I was thinking of having all users in a 'user group' which I could be a member of. Or is this a terrible idea? Should I just 'su' or is there a way around this that I can't think of?
I did search for solutions but as you can imagine 99.9% of the solutions you find are not talking about this specific scenario, more permissions in general.
So to summarise: I want to be able to see what's in user's folders without having to 'su', but leave other users unable to see in each other's folders.
|
The only way to accomplish this without resorting to ACLs is, Permissions set to 750 and your username being a member of every other user's primary group. For instance, lets say you have these users:
me
user1
otheruser
/home will look something like this:
drwxr-x--- 2 me me 4096 Mar 3 12:14 me
drwxr-x--- 24 user1 user1 4096 Apr 8 05:33 user1
drwxr-x--- 2 otheruser otheruser 4096 Feb 11 09:27 otheruser
and in your group file you will see these
me:x:500:
user1:x:501:
otheruser:x:502:
and you are going to add yourself to other users' primary groups and your group fill will look like this:
me:x:500:
user1:x:501:me
otheruser:x:502:me
| User Admin - View Permissions when 750 is used for home |
1,461,478,116,000 |
Yo! I've a ftp server on my linux machine and I've set the following rules: I keep group and owner and chmod it to 775. When I use it at home (192.168.x.x) it's ok, files keep their group and user owner and chmod@775, but when I use it outside (at work for example, I use filezilla portable client), ftp connexion (that I use at home) fails and I need to use sftp, and uploaded files are with the good group and owner but with 755 permissions (the server is configured to chmod files to 775)...And I can't create directories (but of course it works at home, server configured to allow dir creation).
vsftpd.conf:
listen=YES
connect_from_port_20=YES
use_localtime=YES
xferlog_enable=YES
dirmessage_enable=YES
ftpd_banner=myftp.
anonymous_enable=NO
local_enable=YES
write_enable=YES
nopriv_user=publichttp
secure_chroot_dir=/var/run/vsftpd/empty
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list #empty file
allow_writeable_chroot=YES
userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd.user_list
anon_upload_enable=YES
anon_mkdir_write_enable=YES
local_umask=002
file_open_mode=0777
thanks to anyone who have a look at this.
|
Perhaps you overlooked this (from vsftpd.conf(5)):
anon_umask
The value that the umask for file creation is set to for anonymous users. NOTE! If you want to specify octal values, remember the "0" prefix otherwise the value will be treated as a base 10 integer!
Default: 077
| vsftp doesn't respect chmod setting when uploading outside my local network |
1,461,478,116,000 |
I run both Arch Linux and Windows 10 on my computer. When I cd onto the Windows partition (which uses NTFS), I notice that all files and folders have 777 file permissions. I want to run
$ chmod 640 -R * from the partition's root directory to set all file and folder permissions to what they are normally on my linux partition, but I'm a little afraid it might mess up Windows. Is it safe to run this command? Same applies to my external USB hard drive.
|
"Permissions" on NTFS file-systems are a mount option. NTFS doesn't support unix style permissions, ntfs-3g has to fake it with NTFS ACLs.
Use umask=027 on the mount command line (or in /etc/fstab) to get permissions of 640.
See man mount.ntfs for more details and options.
| Is it a good idea to set file permissions to 640 on windows partition? |
1,461,478,116,000 |
Two users, Foo and Bar. Foo wants Bar to work on a project in Foo's home dir.
[foo]$ mkdir project
[foo]$ # Set defaults
[foo]$ setfacl -m d:u::rwx,d:g::rwx,d:o::--- project
[foo]$ # Set defaults overrides for bar
[foo]$ setfacl -m d:u:bar:rwx project
[foo]$ # Set actual acls for project dir
[foo]$ set facl -m u::rwx,g::rwx,o::--- project
Then foo starts creating files and dirs in the new project dir.
Now after ensuring that bar has permission to get to the project dir (i.e. has suitable permissions on all the parent dirs), bar has access to all these files and dirs, and can create their own, which inherit the ACL from project dir.
However, this then means that foo's project folder contains stuff owned by bar, which could might mean foo has no access. e.g.
[bar]$ # feeling annoying...
[bar]$ cd /path/to/project
[bar]$ mkdir -p -m 700 ha/ha
[bar]$ dd if=/dev/zero of=ha/ha/evil bs=1G count=10
Now foo can withdraw bar's access to the project folder, but is stuck with a 10GB file that foo can't access, nor delete!
Is there a way to ensure foo always has full rights over any files/dirs created in a particular directory?
|
With the outdated ACL proposal from 1993 that was withdrawn in 1997, there is no way to do this as bar could always change the permissions in a way that could prevent foo from being able to control things. Note that this ACL proposal did never become a standard because users have been unhappy with it from the beginning.
I recommend to use a more modern filesystem like ZFS that supports the modern ACL standard that was derived from NTFS and is now standardized in the NFSv4 definition. With NFSv4 ACLs, you are able to set up a dedicated ACL that let's foo be the only person that can control ACL definitions and with default ACLs on directories that propagate automatically, the needed permissions can be set up in a way that grant access to bar but not the permission to change the ACLs. See the chmod man page: http://schillix.sourceforge.net/man/man1/chmod.1.html for information on NFSv4 ACLs.
| How can I use ACL to give one user control over a directory and all its contents |
1,461,478,116,000 |
If I am the owner of a file, then is there a way I can give another process (running under another user that doesn't have read/write permission to that file) permission to access it? I want only that specific process (PID) to have access it, not any other process that has the same name as it.
|
What you can do is open the file and pass the file descriptor to the other process over a unix-domain socket using the sendmsg system call with SCM_RIGHTS. You can also determine what user ID is running the remote process by reading the SO_PEERCRED socket option. So taken together this allows you to grant control to a specific process, but it's not as transparent as just having the process open the file.
| Allow a single process to access a file |
1,461,478,116,000 |
I have Redhat 6.3 and I want to enable sudo command for chown,kill and chmod, so under root user I did the following:
visudo
#add the following line
aabuhasna ALL=(ALL) NOPASSWD: /usr/bin/kill, /bin/chmod, /bin/chown
Based on the added line user aabuhasna can do chmod, and chown on any directory or file, but I want to restrict that for one directory for example
if I use the command chown aabuhasna:aabuhasna /test_dir/* it work but if I use chown aabuhasna:aabuhasna /opt/* it fail, the same goes for chmod.
|
Wildcards with sudo commands are a bit dicey. They can appear to give you security without actually doing so. To sudo, the * does not mean "any files under this directory" as it does in the shell. Rather, it means "any additional options" and must stand alone. Unfortunatley, you cannot in sudo restrict part of the arguments, and further, it wouldn't be secure (because the user can specify ../../ which would foil your intentions).
So here's what you do: write a script that carefully validates the command-line arguments and makes sure these don't contain things like ../. Then that script is included in sudo for the user. One more point: bash is a poor choice in this context because of the numerous ways the malicious user can subvert your intent. So here is a perl Example which I've tested and should fit your needs (after customization, and replacing echo with the empty-string).
#!/usr/bin/perl -w
my $user = "aabuhasna";
my $group = "aabuhasna";
my $prefix = "/test_dir";
$mode=shift @ARGV or die "Please provide a mode for the new file";
die "Invalid chmod input: $mode" unless $mode =~ /^[0-9]+$/;
$mode = oct($mode);
die "Invalid permissions in mode: $mode" if $mode != ($mode & 0777);
my $uid = (getpwnam($owner))[2] or die "Unknown user: $user";
my $gid = (getpwnam($group))[2] or die "Unknown group: $group";
foreach (@ARGV) {
die "Invalid Directory Argument: $_" if m:\.\./:;
next if -l $prefix."/".$_;
push @files,$prefix."/".$_;
}
die "No files specified!" unless @files;
chmod $mode, @files;
chown $uid, @gid, @files;
The sudo entry for this script, let's say you put it in /usr/local/bin/changemodeowner is simple:
aabuhasna ALL=(ALL) NOPASSWD: /usr/local/bin/changemodeowner
No * needed here.
| how to enable sudo for one directory |
1,461,478,116,000 |
I want to give SFTP access to user tom for directory /var/www/html/my_project/. while I don't want to give any SFTP access to directory /var/www/html/.
currently /var/www/html/my_project/ and /var/www/html/ is owned by apache user.I need to give access only to /var/www/html/my_project/ directory for both user tom as well as apache.
Once access is given tom can access all the directories which are under /var/www/html/my_project/.
Please help me I am struggling since a long time.
|
I use something like the following in my /etc/ssh/sshd_config file:
Match User tom
ChrootDirectory /var/www/html/my_project/
AllowTcpForwarding no
X11Forwarding no
ForceCommand internal-sftp
Then, make sure tom has permission to access that directory. This can be tricky as tom would need at least 'x' (execute) permissions for all directories above the intended directory. /var/www/html/ is usually accessible to everyone in most flavors of Linux/Unix.
I would probably make the my_project directory owned by tom, and have tom in the apache group. If apache is running as apache:apache (user:group), the following should work for that:
From http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/
# usermod -a -G apache tom
Make whole my_project directory owned by user tom and group apache.
# chown -R tom:apache /var/www/html/my_project/
Make whole my_project directory fully writable to tom, and readable/executable to the apache group.
# chmod -R 750 /var/www/html/my_project/
Note: Any files that tom creates will be owned by tom's user and his default group. The above example adds tom to the group apache, but doesn't make apache his default group. This means the apache server won't have access to new files. To fix that, make apache be tom's default group by useradd -g apache tom.
| How to give sftp access to sub-directory only not to parent |
1,461,478,116,000 |
There are a million versions of this exact question out in google land but I've been unable to solve my problem (sorry). I have created a Samba share on Ubuntu 14.04 (actually xbmcbuntu) that I can connect to and read from, but not write to (from my Mac). I have followed a few different tutorials to get things set up so I probably have configured something incorrectly along the way.
The directory I am sharing (/home/xbmc/raid/media) is owned by the user xbmc and has permissions set to 775.
xbmc@xbmc:~$ ls -al raid
total 28
drwxr-xr-x 4 xbmc xbmc 4096 Sep 4 23:22 .
drwxr-xr-x 23 xbmc xbmc 4096 Sep 4 23:00 ..
drwx------ 2 root root 16384 Sep 2 21:34 lost+found
drwxrwxr-x 9 xbmc xbmc 4096 Sep 4 22:58 media
If I change permissions to 777 I am able to write to the share but this feels like an inappropriate solution.
My smb.conf is as follows;
[global]
workgroup = WORKGROUP
server string = %h server (Samba, XBMC)
netbios name = XBMCbuntu
dns proxy = no
name resolve order = hosts wins bcast
#guest account = xbmc
load printers = no
show add printer wizard = no
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
encrypt passwords = true
passdb backend = tdbsam
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
security = user
username map = /etc/samba/smbusers
[System]
path = /home/xbmc/.xbmc
comment = XBMC System Share
writeable = yes
browseable = yes
guest ok = no
[Media]
path = /home/xbmc/raid/media
comment = xbmc media
writeable = yes
browseable = yes
guest ok = no
and /etc/samba/smbusers is as follows;
xbmc = xbmc
I've done a lot of fiddling with my smb.conf but haven't fixed anything. Any suggestions?
|
Try to add this to [Media] section:
public = no
hide unreadable = yes
printable = no
force create mode = 0664
force group = xbmc
write list = xbmc
directory mask = 0775
Do you authenticate to samba share as user xbmc under MacOS?
| How can I write to my Samba share? |
1,461,478,116,000 |
I have booted my computer using a LiveCD and want to copy a file from a USB drive to the LiveCD loaded desktop.
I want to copy a file from the USB drive to the desktop environment in memory, which has been loaded by the LiveCD. I do not want to copy a file onto the actual LiveCD itself.
I appreciate the copied file will disappear, when the OS loaded via the LiveCD has been switched off.
I have tried the following:
sudo cp "/location_of_usb_file/file.dat" "location_on_live_cd_environment_folder"
But I get the following error:
cp: cannot stat 'file.dat': Permission denied
If I do:
ls -l
I get :
-rw------- 1 ubuntu ubuntu 65546 May 30 12:00 file.dat
How do I copy the file?
|
Due to the internal workings of FUSE¹, it can happen with FUSE filesystems that root cannot access a file, even though some other user could. In such cases, you can change to the owning user to access the file. For example:
sudo -u ubuntu cat "/location_of_usb_file/file.dat" |
sudo tee "location_on_live_cd_environment_folder"
¹ More of a bug than a feature, really, but one that is apparently hard to fix.
| Copy file from USB drive to a desktop loaded via a LiveCD |
1,461,478,116,000 |
I have a laptop with Dual Boot Lubuntu 14.04/Windows 7
I have a BorrajaX user in Lubuntu and another Borrajax user in Windows.
In my Lubuntu $HOME/Documents/ directory I created a link to the Windows BorrajaX user's documents, so I can store things there when in Linux and retrieve them when in Windows, and viceversa.
In Lubuntu, the directory structure is:
/home/borrajax/ drwxr-xr-x borrajax borrajax
|-> Downloads/ drwxr-xr-x borrajax borrajax
|-> Documents/ drwxr-xr-x borrajax borrajax
| |-> TestDir/ drwxrwxr-x borrajax borrajax
| |-> Windows7_Documents -> /media/windows7/Documents and Settings/borrajax/Documents/ lrwxrwxrwx borrajax borrajax
| |-> Android Things/ drwxrwxr-- root plugdev
| |-> desktop.ini -rwxrwxr-- root plugdev
| |-> My Pictures -> /media/windows7/Users/borrajax/Pictures lrwxrwxrwx root plugdev
|-> Pictures/ drwxr-xr-x borrajax borrajax
The link to Windows7_Documents is pointing to a directory in a different partition than where my /home/borrajax is mounted (my $HOME is on /dev/sda5 while the Windows 7 partition is /dev/sda3)
Everything works fine when I access the Windows filesystem locally through that Windows7_Documents link, but now I want to share my Linux $HOME, being able to access that Windows7_Documents remotely, and (here's the issue) I can't. I get a Permission Denied error.
This is how my shared $HOME/Documents/ directory shows on a Mac OS X that is accessing it through Samba:
From the Mac Os X I can properly create new files or directories within my Lubuntu's $HOME/Documents/, but I can't access the link in $HOME/Documents/Windows7_Documents/
Below is the configuration of the Samba share in Lubuntu's config file (/etc/samba/smb.conf):
[borrajax]
path = /home/borrajax
writeable = yes
browseable = yes
valid users = borrajax
hosts allow = 192.168.1. 127.0.0.1
Is there a way to access the Windows7_Documents directory through samba? I suspect it might have something to do with all the files within the Windows7_Documents belonging to root:plugdev ? But if that's the case, how could I make the Samba users belong to the plugdev group (which I guess it would be the best solution? )
Thank you in advance,
|
Try to put following lines into your smb.conf:
follow symlinks = yes
wide links = yes
It seems that Samba does not follow symlinks by default.
| Access through samba to link to different filesystem in shared directory (permission error) |
1,461,478,116,000 |
I had a user john in fedora 19
usergroup marygroup
useradd -g marygroup mary
usermod -a -G marygroup john
In John terminal:
cd /home/mary
Permission denied
cd /home
ls -l
drwx------. 11 john john
drwx------. 11 mary marygroup
logged into as root
chmod 770 /home/mary
ls -l
drwx------. 11 john john
drwxrwx---. 11 mary marygroup
still cannot do cd
Permission denied why?
|
By executing chmod 770 /home/mary all you did was set Read-Write-Execute permission for the Owner User and Owner Group of /home/mary folder (which is mary and marygroup).
If you want to access mary's home as john, you need to add user john to group marygroup:
$ gpasswd -a john marygroup`
For this to take effect, you will have to relogin as user john.
| user accessing and permission denied |
1,461,478,116,000 |
It was a wonder for me to see why the file owner changes when I log in the remote machine with different usernames.
Please see: 1st I logged in a remote machine using username : peacenews.
I entered a directory (pwd outputs / as the directory)
When I run ls to see the files there, I get the below:
(I am only showing the last few lines of the output)
-rwx rwxrwx 1 peacenew 504 198311940 Oct 4 02:21 Rotary club ORC, Delhi .m2p
drwxrwxrwx 2 peacenew 504 4096 Sep 19 23:09 Vizianagaram, AP
-rwxrwxrwx 1 peacenew 504 296817474 Oct 3 10:30 dehradun-prem.VOB
226-Options: -l
226 18 matches total
Then I logged out and reconnected as anonymous user. This time also I logged in the same directory (having the same filenames)
See the output of ls please (last few lines only):
-rwxrwxrwx 1 504 504 198311940 Oct 4 02:21 Rotary club ORC, Delhi .m2p
drwxrwxrwx 2 504 504 4096 Sep 19 23:09 Vizianagaram, AP
-rwxrwxrwx 1 504 504 296817474 Oct 3 10:30 dehradun-prem.VOB
226-Options: -l
226 18 matches total
Have a note at the 3rd column and compare with the previous one. Group owner for the files are the same but file owner changes. How come? It's a wonder!!!
|
I have resolved the matter on my own. I did my research by doing ftp to my own server.
The thing is that the file owner isn't changing. The 1st output shows the username and the 2nd shows the user ID for the same user. So simple but for confirming this I had to experiment with my own server.
| ftp: in remote machine, file owner changes with the change in username used for logging in the remote machine |
1,461,478,116,000 |
I am attempting to mount a cifs drive in standard Ubuntu 12.04.2 LTS using the following line in /etc/fstab:
//server-name/share-name /mnt/archive cifs uid=1002,file_mode=0440,credentials=/etc/.smbcredentials,iocharset=utf8,sec=ntlmi 0 0
This mount will be used to store backups, so I would like to mount it with permissions to create files, but not delete them. Everything seems to be working as it should, except I can go in and delete away with nothing but a warning.
myuser@localhost:/mnt/archive$ ls -l
-r--r----- 0 myuser root 51 Sep 19 17:56 deleteThis.txt
-r--r----- 0 myuser root 51 Sep 19 17:31 deleteThis.txt.bak
myuser@localhost:/mnt/archive$ rm deleteThis.txt.bak
rm: remove write-protected regular file `deleteThis.txt.bak'? y
myuser@localhost:/mnt/archive$ ls -l
-r--r----- 0 myuser root 51 Sep 19 17:56 deleteThis.txt
Why are my file privileges not being respected? Is this an Ubuntu thing?
Is there a way to mount the network share through cifs without exposing the files to deletion?
|
Linux does not manage the permission to delete files separately from the permission to create files. In both cases, what matters is whether you have write permission to the directory. Since you left the default mode for directories, myuser can write to /mnt/archive and therefore can delete files there as well as create them.
rm prompts for confirmation when you try to delete a read-only file, but that doesn't mean that you don't have the permission to delete it: it means that you do have the permission to delete it but rm thinks it might be a bad idea to do so.
You can prevent users from deleting files that they do not own by setting the “sticky bit” on the directory (chmod +t), as is done for /tmp. Use the mount option dir_mode=1755.
You cannot prevent users from deleting their own files except by not giving them the permission to create files in that directory either.
It is odd to allow users to create files that they cannot delete. If you really want that, you'll need something more flexible than classical unix file permissions or Solaris/Linux ACLs (I think you can do it with OSX ACLs).
| mount.cifs not respecting file permissions in Ubuntu 12.04.2 LTS |
1,461,478,116,000 |
I am new to system administration. We have a lab set up where we have a server and client machines. The client machines have LDAP users which has the work area for all the users in the centralized server. So whenever an user logs in, his work area will be mounted through the NFS service in the client machines and all his work will be saved to the server when he logs out.
Now, I want to give a local user in the server limited root access. I want this local user to be able to view the home directory of all the LDAP users and nothing else. I believe I am looking for wheel user in the server. I also believe I should make some changes in the visudo file to allow limited root access to the local user in the server.
user1, %operator ALL= /home/users
I tried adding the above command in the visudo file for the local user user1.
I also added the user to the wheel group like below.
usermod -G 10 user1
However, I do not see any changes. Why didn't my approach with sudo work?
Since this approach doesn't seem to be working, I asked: Allow a user to read some other users' home directories
|
Couple of things:
The command sudo is for elevating yourself to a higher level of credentials for either a command or set of commands, not for gaining access to a directory with which you (1) aren't either the owner, (2) in a group that has read permissions to said directory, or (3) the directory doesn't have the other permissions opened to the world.
The file /etc/sudoers is the file that contains all the rules for a given system and stipulates which users, groups of users, can run which commands in an elevated way as root, typically, or some other user account. You typically do NOT want to edit this file directly, though you can, it's best not to do so.
The command visudo is the prescribed way for editing the /etc/sudoers file.
If you want to see what sudo credentials a user has access to, the simplest way is to become that user and run the command, sudo -l.
$ sudo -l
Matching Defaults entries for saml on this host:
env_reset, env_keep="COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS", env_keep+="MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE",
env_keep+="LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES", env_keep+="LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE", env_keep+="LC_TIME LC_ALL
LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY", secure_path=/sbin\:/bin\:/usr/sbin\:/usr/bin
User saml may run the following commands on this host:
(ALL) ALL
(root) NOPASSWD: /usr/lib/jupiter/scripts/bluetooth, (root) /usr/lib/jupiter/scripts/cpu-control, (root) /usr/lib/jupiter/scripts/resolutions, (root)
/usr/lib/jupiter/scripts/rotate, (root) /usr/lib/jupiter/scripts/touchpad, (root) /usr/lib/jupiter/scripts/vga-out, (root) /usr/lib/jupiter/scripts/wifi
wheel access
I believe you're referring to the users' group wheel, which is an old way (to my knowledge) way of granting users permissions to become root via su -. This article does a good job of discussing the use of this group, titled: Administering your Linux system.
Granting access to /home/<user>?
To my knowledge there is no systematic way to do this without giving this user elevated privileges in other ways that you're trying to limit. I would say that if you do not trust this particular user the responsibility of having access in this fashion then they are probably not the right person to be doing this work!
Groups
For example. Say I have 2 students and 1 TA. Students (user1 & user2) TA (user3).
So the groups would be as follows:
class1
vboxuser1
So when I logged into the system as any of the above users (1-3), my groups would be as follows:
$ groups
users vboxusers class1
This groups would also need to be set on the student's home dirctories:
$ ls -l /home/user1 | head -3
total 37784
drwxrwxr-x 2 saml class1 4096 May 16 22:02 alsa
drwxrwxr-x 31 saml class1 4096 Mar 26 12:09 apps
This is just one idea, it has issues with this approach, but given the information you've provided is "one way to do it"!
| Allow a user to view the home directory of other users via sudo |
1,461,478,116,000 |
I am running Linux Slackware 14.0. I wanted to allow to do su only to the members of wheel group, so I modified the permissions of /bin/su and /usr/bin/sudo files to this:
bash-4.2# ls -la /bin/su
-rws--s--- 1 root wheel 59930 Sep 14 2012 ./su
bash-4.2# ls -la ./sudo
-rws--s--- 1 root wheel 107220 Jun 29 2012 ./sudo
Now when I am a member of wheel group and run su, it promts for password, I enter it. No errors are shown, but doesn't switch me to root. Probably, I set some permissions wrong?
|
You could try
chown root.wheel /bin/su
chmod o-x /bin/su
so su will belong to wheel group and the others won't be able to run it. It seems to me that chown should solve your problem, setting properly all the permissions, since you just set up the execution rights previously.
| Can't run su after changing permissions to su file |
1,461,478,116,000 |
I just created a script (logscreenlock) to log lock/unlock screen events (derived from this post):
#! /bin/bash
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | ( while true; do read X; if echo $X | grep "boolean true" &> /dev/null; then echo `date` "screen locked"; elif echo $X | grep "boolean false" &> /dev/null; then echo `date` "screen unlocked"; fi done )
I wanted to have a startup daemon running logscreenlock > /var/log/screenlock.log. Now, to write into /var/log, I need root permissions (I am a sudoer). So I would need sudo logscreenlock > /var/log/screenlock.log, but I have two problems with that:
logscreenlock is owned by my user and and I would like to keep it that way, but even after chmod a+x logscreenlock, I get permission denied if I try to sudo ./logscreenlock. I tried to usermod -a -G <myusergroup> root, but no luck. How can I overcome this?
How can I sudo in the startup applications? will it prompt me for a password right away?
EDIT: I found out later that the reason why I couldn't execute logscreenlock as root was that this script is in a remote filesystem where my machine's root is not authenticated.
|
Assuming your username and group are ricab, have you tried sudo chgrp ricab /var/log/screenlock.log and sudo chmod g+rw /var/log/screenlock.log? You should then be able to read and write screenlock.log using your account.
| Execute user script as root in startup applications |
1,461,478,116,000 |
This would be illustrated very nicely with an scheme. When I write "Test: OK" or "Test: FAIL" I am restarting apache server (httpd service). Basically, performing everything as root in the target_host:
scp user@source_host:/etc/httpd/conf.d/custom.conf /home
mv /home/custom.conf /etc/httpd/conf.d/
Test: FAIL
scp user@source_host:/etc/httpd/conf.d/custom.conf /etc/httpd/conf.d/
Test: OK
scp user@source_host:/etc/httpd/conf.d/custom.conf /
mv /custom.conf /etc/httpd/conf.d/
Test: OK
The same behaviour when using:
scp root@source_host...
When Test: FAIL:
Iniciando httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Could not open configuration file /etc/httpd/conf.d/custom.conf: Permission denied
"Iniciando" is the Spanish word for Starting
The permissions inside conf.d are always (ls -ln):
-r--r--r--. 1 0 0 311 Jun 18 14:19 custom.conf
Is scp changing something in these files so that apache can or not read them?
|
From drupalwatchdog.com
SELinux will block Apache processes from reading data labeled as
user's home content (user_home_t) or database data (mysql_db_t).
I have learned too that the difference resides in the label's assigned to the files by SELinux. You can check them by ls -Z. In my case:
-r--r--r--. root root unconfined_u:object_r:home_root_t:s0 custom.conf
-r--r--r--. root root unconfined_u:object_r:httpd_config_t:s0 custom_ok.conf
With the second file Apache restarts. With the first one fails.
In fact, when I move the custon_ok.conf to home, nothing changes. But when I do cp or cp -p to home, the new file has the labels
unconfined_u:object_r:home_root_t:s0
so that Apache will not be able to read it when moved back to /etc/httpd/conf.d
| scp to /home changes permissions? |
1,461,478,116,000 |
Can I share a folder inside my home directory with another user?
I have two users on a system, agent and daemon. An external server connects as agent and rsyncs files to ~agent/incoming
I want daemon to have access to the files in ~agent/incoming but I don't want agent to have access to any of daemon's files.
I set up a group called automaton and added both users to it. I then chmod'ed the ~agent/incoming folder to drwxrws--- (notice the sticky bit) and chowned that folder to agent:automaton.
The process runs and new files are delivered to the incoming folder and are set as agent:automaton with permissions -rw-rw---- but daemon is not able to view or copy these files:
stat: cannot stat (path here) : Permission denied
What am I doing wrong?
|
Your question is difficult to answer precisely because you haven't said what path you're passing to the daemon and you haven't specified the permissions of ~agent. If you start the daemon in the ~agent/incoming directory and pass it relative paths, then since the daemon is in the automaton group it will be able to read, write and delete the files in the ~agent/incoming directory.
I guess what's happening is:
The ~agent directory is not executable to the daemon.
The path passed to the daemon includes ~agent as a component (say, it's an absolute path).
When a process accesses /home/agent/incoming/foo, it must have execution permissions on all the directories that are traversed: /, /home, /home/agent and /home/agent/incoming (more if some of these are symbolic links).
If the daemon accesses foo while its current directory is ~agent/incoming, it only needs to have execution permissions on the current directory (~agent/incoming) itself. You need to manage to make that directory current; chdir requires that the process have access to the target directory. This is possible if you first change to the desired directory while running as (say) the agent user, then run something like su daemon -c daemon-command.
| Can I share a folder inside my home directory with another user? |
1,461,478,116,000 |
I'm kind of new to using NFS in the context of Linux permissions, so I'm a little lost on how I can make this work.
Here's my setup:
alpha writes files as root to the mounted NFS share.
beta serves NFS and reads files from the shared directory, as well as serves the files out over HTTP. The HTTP server runs as user blaster with group server.
The dilemma I'm facing is that files are written as root on alpha and can't read or written by user blaster of group server on beta.
The question is: how can I fix this? Do I have to create user blaster and group server on alpha and write files using this user and group in order to allow things to be shared with beta?
|
Writing files as root to an NFS share (by an NFS client) is a really bad idea. So bad, that the default is to not permit this.
If you want the same privileges on beta as on alpha, then you need to create users with the same User ID on both machines and groups with the same Group ID on both machines. The actual names are irrelevant, though it is really handy that they are the same.
| Sharing files with NFS and Unix Permissions |
1,461,478,116,000 |
I need to know how to check the effective file access permissions for a given user, but it takes long to do this manually starting from / up to the target file or directory, checking group, ...etc.
|
From what I see, the only ways would be to either do what you describe, check each of the permissions sets against the effective user/group. Or you could try to set up sudo to be able to take test(1).
sudo -u luser test -x ~juser/bin/myprogram
Like you said, check the effective user/groups permissions:
:
# called as $0 usertocheck pathname {r|w|x}
# for example, permcheck luser ~juser/bin/myprogrm x
# displays either "root", "user", "groups", "other" or "none"
user=$1
file=$2
smode=$3
# if user has no access from state, an empty string is returned, fuid,
# fgid and fmode would become empty strings as well; the end result is
# always showing 'none' even if $user has access (except $user == 'root')
set -- $(stat -L -c '%u %g %a' $file 2>&-)
awk -f $tmpawk \
-veuid="$(id -u $user)" \
-vgrp="$(id -G $user)" \
-vfuid="$1" \
-vfgid="$2" \
-vfmode="$(echo ibase=8\;$3 | bc)" \
-vsmode="$smode" \
'BEGIN {
if (euid == 0) { print "root"; exit; }
split(grp,Groups);
omode = fmode % 8; gmode = int(fmode / 8 % 8);
umode = int(fmode / 64 % 8);
# set up tests
# these could be function, but not all version of awk has a function
# statement
if (smode == "r") {
utest = int(umode / 4);
gtest = int(gmode / 4);
otest = int(omode / 4);
}
if (smode == "w") {
utest = int(umode / 2 % 2);
gtest = int(gmode / 2 % 2);
otest = int(omode / 2 % 2);
}
if (smode == "x") {
utest = (int(umode >= 4) && umode % 2);
gtest = (int(gmode >= 4) && gmode % 2);
otest = (int(omode >= 4) && omode % 2);
}
if (utest && fuid == euid) { print "user"; exit; }
for (idx in Groups) {
if (gtest && Groups[idx] == fgid) { print "group"; exit; }
}
if (otest) { print "other"; exit; }
print "none";
}
'
On my Ubuntu 11.04 system, running this script takes about 16ms, on average. Also, stat does not need read/execute per
| A command to check file access permission for another user |
1,461,478,116,000 |
I'm using x64 Ubuntu. A few months ago I accidentally messed up the groups/owners of all files on /, but managed to fix it using a VirtualBox install of Ubuntu.
Now I'm running into a problem that I think is related to that mistake. When I try to reinstall ia32-libs (Skype is having problems so I need to reinstall those libs) I get an error message:
/var/lib/dpkg/info/ia32-libs.postinst: 40: /usr/lib32/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders: Permission denied
ls -al /usr/lib32/gdk-pixbuf-2.0/` is this:
total 476
drwxr-xr-x 3 root root 4096 2011-09-24 17:08 .
drwxr-xr-x 53 root root 143360 2011-09-24 17:08 ..
drwxr-xr-x 3 root root 40 2011-09-24 04:44 2.10.0
-rwxr-xr-x 1 root root 9648 2011-04-05 00:40 gdk-pixbuf-query-loaders
I have tried to reinstall gdk-pixbuff-2.0, but it didn't work. How can I fix this?
|
Run ldd /usr/lib32/gdk-pixbuf-2.0//gdk-pixbuf-query-loaders and make sure every file is accounted for (the line must end with an address like (0xf7789000)). In particular, check the permissions on the dynamic loader /lib/ld-linux.so.2. This is the only file in the lot that could cause that particular error message, but you may need to fix other permissions while you're at it.
chown root:root /lib*/*
chmod a+rx /lib*/ld-* /lib*/*/
chmod -R a+r /lib
| Problem when installing “ia32-libs” |
1,461,478,116,000 |
Has anyone ever encountered a scenario where you are logged into a system going about your standard business, cat, ls, tail, grep, vim, find etc. and suddenly permissions to regular things stop working? When I do a whoami it turns out I'm not my regular user but another user.
For example
bash>whoami
mark
bash>cat /dev/null > perm.mark
bash>clear
bash>tail -f perm.mark
bash>^C
bash>cat /dev/null > perm.mark
permission denied
bash>whoami
adam
Any ideas about what's happening here?
|
Turns out that this was a problem with the LDAP for the domain. The mark user was cloned from Adam, as a result he ended up with the same user id group id etc. etc. I tar'd the contents of mark's home directory. Then destroyed mark from the ldap server and created him again from scratch. Looks like it all works now.
| Suddenly changing users [closed] |
1,310,590,711,000 |
I accidentlly changed ownership of /usr/bin/sudo to my current user (i also did this for some other stuff in my /usr directory). I can't change any of them back because I need ownership of /usr/bin/sudo to be root to do so. I do not have root access because I'm on an Amazon EC2 instance running linux.
Here's what I did (foolishly I know):
sudo chown -R currentuser.currentuser /usr/
I've also hosed a ton of other stuff in the process, but I think it can all be solved if I can reset ownership of /usr/bin/sudo
Please help. I'm brand new to Linux admin and am doing everything from the command line.
EDIT: I used -R in my sudo chown command.
EDIT2: I have most of my data on a separate, mounted EBS, but I'm awful with server admin and it'll probably take me an entire day to setup a new instance.
|
There was no solution that allowed me to fix this problem from within that system with that user. I could not get root access, and there was no trick to get around the problem.
I had to ditch the server and start anew.
| How do I reset ownership on /usr/bin/sudo on centOS? [closed] |
1,310,590,711,000 |
If I follow a process I mentioned here, I am supposed to log out and then in for the changes to take place. What about Nautilus? I tried to restart it and was still unsuccessful. The only way I have so far found that works is logging out of the desktop and then in again. That's not always convenient of course.
|
You can't grant a new group to a running process. You need to log in again to get a process with the changed group memberships.
What you can do is to launch nautilus from a different session but have it display on your existing display, something like
ssh localhost "DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY nautilus &"
| How to make Nautilus notice changes regarding group permissions |
1,310,590,711,000 |
I've an issue with files ownerships in unix.
I have a drupal website and the "files" folder needs to be owned by "www-data" in order to let the users to upload files with php.
However I'm now using svn and I need all folders and files to be own by "svnuser" in order to work.
So now, I guess I need to add both users to a group with proper permissions. I'm not sure what exactly to do, could you tell me what are the exact necessary steps ?
thanks
|
The easiest way to manage this is with access control lists. They allow permissions to be set for as many users and groups as you want, not just one user and one group like the basic unix permissions.
ACLs need to be enabled on the filesystem. With ext[234] or reiserfs, you need to pass the acl mount option. Also make sure you have the ACL utilities installed (acl package on Debian or Ubuntu).
Set an ACL that allows both users to access the files, and set a matching default ACL on directories (the default ACL is inherited by files created in the directory).
setfacl -m user:www-data:rwx -m user:svnuser:rwx -R /path/to/directory/tree
setfacl-d -m user:www-data:rwx -m user:svnuser:rwx -R /path/to/directory/tree
You can set different permissions if you like. The executable bit will be ignored if the file is not made executable through the non-ACL permissions (the ones you set with chmod).
The commands given are for Linux. Many other unix variants support ACLs, but the exact set of available permissions and the utility to set them are not standardized.
You can use groups to control access if you want. Even if you do, ACL have the advantage that you won't run into a umask issue: if you just create a group, you have to ensure that all files and directories are group-writable, which means you have to make sure any process creating a file has a umask of 002 or 007, which in turn may cause permissions elsewhere to be more liberal. So even if you create a group, ACLs are useful.
setfacl -m group:mygroup:rwx -R /path/to/directory/tree
setfacl -d -m group:mygroup:rwx -R /path/to/directory/tree
Note that I make no warranty as to the suitability of this security model to your use case. I'm just providing an implementation.
| How to assign correct permissions to both webserver and svn? |
1,310,590,711,000 |
I am pretty sure it is a stupid mistake but I can't seem to figure it out by myself, so please have a look.
I set up an ACL for the current folder like so:
zigbee2mqtt@nuc:/tmp/folder$ getfacl .
# file: .
# owner: zigbee2mqtt
# group: zigbee2mqtt
user::rwx
user:stack:r-x
user:zigbee2mqtt:rwx
user:milkpirate:rwx
group::---
mask::rwx
other::---
default:user::rwx
default:user:stack:r-x
default:user:zigbee2mqtt:rwx
default:user:milkpirate:rwx
default:group::---
default:mask::rwx
default:other::---
zigbee2mqtt@nuc:/tmp/folder$ id
uid=978(zigbee2mqtt) gid=977(zigbee2mqtt) groups=977(zigbee2mqtt)
so when I now create a folder/file in that folder like so:
zigbee2mqtt@nuc:/tmp/folder$ touch foo; mkdir bar
It results in the following permission on the folder foo:
zigbee2mqtt@nuc:/tmp/folder$ getfacl foo
# file: foo
# owner: zigbee2mqtt
# group: zigbee2mqtt
user::rwx
user:stack:r-x
user:zigbee2mqtt:rwx
user:milkpirate:rwx
group::---
mask::rwx
other::---
default:user::rwx
default:user:stack:r-x
default:user:zigbee2mqtt:rwx
default:user:milkpirate:rwx
default:group::---
default:mask::rwx
default:other::---
which looks fine so far.
But the ACL of the file then looks off:
# file: bar
# owner: zigbee2mqtt
# group: zigbee2mqtt
user::rw-
user:stack:r-x #effective:r--
user:zigbee2mqtt:rwx #effective:rw-
user:milkpirate:rwx #effective:rw-
group::---
mask::rw-
other::---
I would expect the mask to be rwx (desired).
Since group and other are --- (desired) the permission in ls -la to be the same, but they are:
zigbee2mqtt@nuc:/tmp/folder$ ls -la
total 20
drwxrwx---+ 3 zigbee2mqtt zigbee2mqtt 4096 Jan 15 17:55 .
drwxrwxrwt 16 root root 4096 Jan 15 17:59 ..
-rw-rw----+ 1 zigbee2mqtt zigbee2mqtt 0 Jan 15 17:55 bar
drwxrwx---+ 2 zigbee2mqtt zigbee2mqtt 4096 Jan 15 17:55 foo
but I would expect (and desire):
zigbee2mqtt@nuc:/tmp/folder$ ls -la
total 20
drwxrwx---+ 3 zigbee2mqtt zigbee2mqtt 4096 Jan 15 17:55 .
drwxrwxrwt 16 root root 4096 Jan 15 17:59 ..
-rw-------+ 1 zigbee2mqtt zigbee2mqtt 0 Jan 15 17:55 bar
drwx------+ 2 zigbee2mqtt zigbee2mqtt 4096 Jan 15 17:55 foo
EDIT:
Ok, did some testing and all seems to work as desired, the result of ls -la does not seem to reflect the correct rights:
zigbee2mqtt@nuc:/tmp/folder$ sudo -u nginx -g zigbee2mqtt bash
nginx@nuc:/tmp/folder$ ls
ls: cannot open directory '.': Permission denied
|
What you see in the ls listing are the "traditional" permission bits, all you'd have in a system that doesn't support ACLs, and all that can be used by tools (or users!) that aren't ACL-aware.
The "traditional" group permission bits don't correspond to the owning group ACL, but to the ACL mask (acl(5) man page):
CORRESPONDENCE BETWEEN ACL ENTRIES AND FILE PERMISSION BITS
The permissions defined by ACLs are a superset of the permissions
specified by the file permission bits.
There is a correspondence between the file owner, group, and other
permissions and specific ACL entries: the owner permissions
correspond to the permissions of the ACL_USER_OBJ entry. If the ACL
has an ACL_MASK entry, the group permissions correspond to the
permissions of the ACL_MASK entry. Otherwise, if the ACL has no
ACL_MASK entry, the group permissions correspond to the permissions
of the ACL_GROUP_OBJ entry. The other permissions correspond to
the permissions of the ACL_OTHER entry.
What the mask does, is limit the permissions that can be granted by ACL entries for named users, named groups, or the owning group. In a way, you can think of the three sets of "traditional" permission bits as applying to 1) the owning user, 2) other explicitly defined users (without ACLs: members of a the owning group; with ACLs: those plus other named users or members of other named groups), and 3) everyone else.
The practical reasoning there is that if a user or program wants to make sure only the owner has write permissions to the file, something like chmod go-w still works to do that, even without the actor knowing about ACLs.
So, having it show rwx for the group in the ls listing is by design, since you have the user:zigbee2mqtt:rwx and user:stack:r-x ACL entries there. The ls output just hints that there are some others apart from the owning user who have read, write and/or execute permissions on the file. Setting the mask to 000 (with e.g. chmod g-rwx or the appropriate setfacl command) would make those ACL entries for user:zigbee2mqtt and user:stack ineffective.
When you create a file with touch, and see mask::rw- on it, that's because touch and most other tools create regular files with permissions 0666, not 0777, leaving the x bits off. Most files shouldn't be executable. Regardless of the ACLs, the permissions passed to the open() system call still count, the same as if the permissions were changed with chmod(). Apart from leaving the x bits off, this allows a program to create private files by setting the permissions bits to 0600.
| touch/mkdir seems to ignore default ACL |
1,310,590,711,000 |
I am trying to install the VMware client on my work computer, which is running CentOS 7 and on which I have superuser privileges.
When I run the command
sudo ./VMware-Horizon-Client-5.2.0-14604769.x64.bundle
I get the following error message
sudo: unable to execute ./VMware-Horizon-Client-5.2.0-14604769.x64.bundle: Permission denied
When I run the same command without sudo the file executes, but the installer brings up a dialog box with the following error message
root access is required for the operations you have chosen.
I've checked the file's permissions, and I have execute privileges. I've even tried temporarily setting the privileges to 777, but it made no difference. Moving the file to another directory doesn't seem to help. I've run df and then mount to make sure noexec isn't set for this device, and it is not.
I've successfully installed programs on this computer before, so this behaviour seems particularly odd. Does anyone have any suggestions on how I might get this to work or other ways I might try installing the VMware client?
|
It sounds like you have NFS homes, and that the file is on a Kerberized NFS share, which means that even root can't read things in it. To work around it, as yourself (not root), copy the file to somewhere that isn't NFS (like /tmp), and then run it from there (or if /tmp is noexec, once it's there, copy it to somewhere else as root).
| Unable to execute file with superuser priviliges |
1,565,963,012,000 |
I've been trying to install TeemIP for about 6+ months now and I've never been able to figure out this issue on Centos7.
The error I get is the following:
The directory '/var/www/teemip/public_html/web/log' exists but is not
writable for the application.
TeemIp needs the directory '/var/www/teemip/public_html/web/env-production' to be writable. The
directory '/var/www/teemip/public_html/web/env-production' does not
exist and '/var/www/teemip/public_html/web/' is not writable, the
application cannot create the directory 'env-production' inside it.
TeemIp needs the directory
'/var/www/teemip/public_html/web/env-production-build' to be
writable. The directory
'/var/www/teemip/public_html/web/env-production-build' does not exist
and '/var/www/teemip/public_html/web/' is not writable, the
application cannot create the directory 'env-production-build' inside
it.
TeemIp needs the directory '/var/www/teemip/public_html/web/conf' to
be writable. The directory '/var/www/teemip/public_html/web/conf'
does not exist and '/var/www/teemip/public_html/web/' is not
writable, the application cannot create the directory 'conf' inside
it.
The directory '/var/www/teemip/public_html/web/data' exists but is
not writable for the application.
I have created a user and group called www-data for the apache httpd and the permissions are as follows:
[root@TeemIP html]# ls -l
total 648
drwxrwsr-x. 3 www-data www-data 24 Apr 7 21:24 addons
drwxrwsr-x. 3 www-data www-data 4096 Apr 7 21:24 application
-rwxrwxr-x. 1 www-data www-data 245 Apr 7 21:24 approot.inc.php
drwxrwsr-x. 3 www-data www-data 4096 Apr 7 21:24 core
drwxrwsr-x. 6 www-data www-data 4096 Apr 7 21:24 css
drwxrwsr-x. 2 www-data www-data 58 Apr 7 21:24 data
drwxrwsr-x. 3 www-data www-data 17 Apr 7 21:24 datamodels
drwxrwsr-x. 2 www-data www-data 4096 Apr 7 21:24 dictionaries
drwxrwsr-x. 2 www-data www-data 30 Apr 7 21:24 documentation
drwxrwsr-x. 2 www-data www-data 24 Apr 7 21:24 extensions
drwxrwsr-x. 4 www-data www-data 8192 Apr 7 21:24 images
-rwxrwxr-x. 1 www-data www-data 1030 Apr 7 21:24 index.php
drwxrwsr-x. 7 www-data www-data 4096 Apr 7 21:24 js
drwxrwsr-x. 7 www-data www-data 84 Apr 7 21:24 lib
drwxrwsr-x. 2 www-data www-data 58 Apr 7 21:24 log
-rwxrwxr-x. 1 www-data www-data 603311 Apr 7 21:24 manifest.xml
drwxrwsr-x. 2 www-data www-data 4096 Apr 7 21:24 pages
drwxrwsr-x. 3 www-data www-data 55 Apr 7 21:24 portal
drwxrwsr-x. 5 www-data www-data 4096 Apr 7 21:24 setup
drwxrwsr-x. 5 www-data www-data 73 Apr 7 21:24 sources
drwxrwsr-x. 2 www-data www-data 141 Apr 7 21:24 synchro
-rwxrwxr-x. 1 www-data www-data 630 Apr 7 21:24 web.config
drwxrwsr-x. 2 www-data www-data 4096 Apr 7 21:24 webservices
From what I understand, the application, TeemIP, is using the http daemon to write to logs and create directories. The httpd.conf file includes the www-data user and group, the config is below.
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User www-data
Group www-data
# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition. These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed. This address appears on some server-generated pages, such
# as error documents. e.g. [email protected]
#
ServerAdmin root@localhost
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
I tried:
Apache2 permissions issue
I also tried changing the user and group to a sudo user and group, but it didn't make a difference. I changed the owner of the /var/www directory to www-data and changed the permissions of the /var/www directory to 775 (recursively). Also, I created the www-data user and group specifically for the apache daemon, but I didn't do anything more than adduser user and groupadd group.
Let me know if you need any other information. I am not sure where else to look, as I do not have intermediate or expert level knowledge on Linux systems.
|
SELinux is there for a reason. It enforces access restrictions above the standard file system permissions and really makes your server more secure.
You should try to make this work with SELinux enforced :-)
You need to figure out which TeemIP web directories are to be readonly and which are to be writable by Apache. Then, using the instructions in https://wiki.centos.org/HowTos/SELinux (specifically the parts about relabeling files [5.2]), relabel the directories accordingly.
You would typically use semanage fcontext -a -t httpd_sys_content_t "/<pathspec>(/.*)?" for readonly directories and semanage fcontext -a -t httpd_sys_rw_content_t "/<pathspec>(/.*)?" for writable directories. Then, run a restorecon -Rv on the webroot to see the magic happen.
Using commands like ausearch -ts recent -m avc -i while running in permissive mode (setenforce 0) you can check the SELinux audit log for access problems. You may even get hints how to fix SELinux errors by issueing audit2why -a or piping individual audit log entries to audit2why.
Once TeemIP works without triggering new entries in the SELinux audit log, you're good to go: setenforce 1.
Good luck!
| Website cannot write to files or create directories |
1,565,963,012,000 |
I have installed rust by curl https://sh.rustup.rs -sSf | sh and followed instructions thereof. Installation was successful and the PATH was added to the .bash_profile as follows:
export PATH=$HOME/.cargo/bin:$PATH
echo ing $PATH shows variable has been set properly, as follows:
rust@rusty:~$ echo $PATH
/home/rust/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
I am mounting /home as a separate partition and mounting through /etc/fstab as follows
# Mounting home partition
/dev/sda4 /home ext4 rw,async,users 0 0
I initially had noexec as one of the options. But, removing that did not bring any change in the outcome.
I doubting that my default /home partition permissions but don't have any other linux running box to verify.
total 20
drwx------ 2 root root 16384 Jan 18 08:38 lost+found
drwxr-xr-x 22 rust rust 4096 Jan 19 19:45 rust
Is this permissions correct?
If someone could shed some light on what I am missing to notice/doing wrong and how to troubleshoot and fix the issue would be much appreciated.
Realized after the comment from @kusalananda
EDIT-1
rust@rusty:~$ cargo
bash: /home/rust/.cargo/bin/cargo: Permission denied
It supposed to prompt me with the help documentation of cargo but fails saying the above.
EDIT-2
Added the permissions of .cargo and .cargo/bin
rust@rusty:~$ ls -l .cargo/
total 8
drwxr-xr-x 2 rust rust 4096 Jan 19 18:45 bin
-rw-r--r-- 1 rust rust 37 Jan 19 18:58 env
rust@rusty:~$ ls -l .cargo/bin/
total 108560
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 cargo
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 cargo-clippy
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 cargo-fmt
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rls
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rustc
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rustdoc
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rustfmt
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rust-gdb
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rust-lldb
-rwxr-xr-x 10 rust rust 11116056 Jan 19 18:45 rustup
EDIT-3:
>> curl https://sh.rustup.rs -sSf | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
/home/rusty/.cargo/bin
This path will then be added to your PATH environment variable by modifying the
profile files located at:
/home/rusty/.profile
/home/rusty/.bash_profile
You can uninstall at any time with rustup self uninstall and these changes will
be reverted.
Current installation options:
default host triple: x86_64-unknown-linux-gnu
default toolchain: stable
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2019-01-17, rust version 1.32.0 (9fda7c223 2019-01-16)
info: downloading component 'rustc'
79.5 MiB / 79.5 MiB (100 %) 883.2 KiB/s ETA: 0 s
info: downloading component 'rust-std'
54.3 MiB / 54.3 MiB (100 %) 611.2 KiB/s ETA: 0 s
info: downloading component 'cargo'
4.4 MiB / 4.4 MiB (100 %) 761.4 KiB/s ETA: 0 s
info: downloading component 'rust-docs'
8.5 MiB / 8.5 MiB (100 %) 553.6 KiB/s ETA: 0 s
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
info: default toolchain set to 'stable'
stable installed - (error reading rustc version)
Rust is installed now. Great!
To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done automatically.
To configure your current shell run source $HOME/.cargo/env
|
The issue was the /etc/fstab entry that I had. It worked after I changed the way I was mounting. Here is my new fstab entry:
/dev/sda4 /home/rusty ext4 defaults 0 2
I changed the owner & group of /home/rusty to be rusty and it worked.
| cargo execution - permission denied [PREVIOUSLY]rust installation - permission denied |
1,565,963,012,000 |
I'm probably missing something glaringly obvious..... but I can't see it.
I have an ordinary directory on FreeBSD, controlled by NFSv4 ACLs. The ACLs say I can list its contents; but I can't.
Here's the getfacl output on the problem dir and its parent + grandparent:
# getfacl /mnt/data_dir/working_dir/
# owner: root
# group: wheel
group:data_managers:-w-pDd--------:-------:deny
everyone@:r-------------:-------:allow
group:data_managers:rwxpDda-R-c---:fd-----:allow
owner@:--------------:fd-----:allow
group@:--------------:fd-----:allow
everyone@:--x-----------:-d-----:allow
# file: /mnt/data_dir
# owner: root
# group: wheel
owner@:rwxpDdaARWcCos:fd-----:allow
group@:rwxpDdaARWcCos:fd-----:allow
everyone@:r-x---a-R-c---:fd-----:allow
# file: /mnt
# owner: root
# group: wheel
user::rwx
group::r-x
other::r-x
I su as the newly created account having the ACL issue. This account is not the owner of any relevant dirs, nor a member of wheel or data_managers, so its only rights stem from the "everyone (world)" permissions/ACLs.
$ su -f restricted_user
% id
uid=1100(restricted_user) gid=65533(nogroup) groups=65533(nogroup),4003(restricted_users)
% pwd
/mnt/data_dir/working_dir
% ls
ls: .: Permission denied
I don't get it. The world permission on that dir is everyone@:r ..... (inheritance downward to subdirs for "x" but not "r"). r should give worldwide rights to read the contents of working_dir. It's not a member of data_managers and if it was, the deny ACE isn't denying r or x. I can traverse to it. But I can't read its contents.
What have I missed?
|
Now explored and reproducible, filed as a bug in FreeBSD ACL evaluation:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=228538
| getfacl says my unprivileged account should be able to read the contents of a dir, but it can't |
1,565,963,012,000 |
I'm trying to change umask mode using login.defs config file but for some reason it doesn't affect the system.
This is what I do: sudo nano /etc/login.defs
# The ERASECHAR and KILLCHAR are used only on System V machines.
# The ULIMIT is used only if the system supports it.
# (now it works with setrlimit too; ulimit is in 512-byte units)
#
# Prefix these values with "0" to get octal, "0x" to get hexadecimal.
#
ERASECHAR 0177
KILLCHAR 025
UMASK 027
Trying to change UMASK 027 to UMASK 007 and it changes.
Next:
# Enable setting of the umask group bits to be the same as owner bits
# (examples: 022 -> 002, 077 -> 007) for non-root users, if the uid is
# the same as gid, and username is the same as the primary group name.
#
# This also enables userdel to remove user groups if no members exist.
#
USERGROUPS_ENAB yes
Changing USERGROUPS_ENAB yes to USERGROUPS_ENAB no after that I save the file and do log out and log in and trying to create a file for example:
touch file ~/
and the output for file
stat -c %a ~/file
gives 644 and not expected 640. I remember I did this workaround some time ago and it worked perfectly fine.
Is there some other workaround or explanation?
This is my kernel information:
Linux 4.13.8-1-ARCH #1 SMP PREEMPT Wed Oct 18 12:11:48 CEST 2017 i686 GNU/Linux
|
Thanks for the comments who ever tried to help me. So I happened to make umask 027 mode permanent by changing ~/bashrc file. For a fact I didn't have any umask sets in that file, so I added these lines at the end of the text:
#umask mode
umask 027
And after system log out and log in it seems to overwrite this rule for entire system, now the newly created files have permission 640
| Cannot change the umask mode |
1,565,963,012,000 |
I have a set of Linux workstations that only approved users should be plugging in approved USB storage devices. How can I restrict mounting new USB devices to certain groups? And is there a way to reject unrecognised devices?
|
You probably want to look into a piece of software called USBGuard. It's designed specifically for handling this. Unfortunately it's not pre-packaged for many distros, but it is pretty easy to build locally and you probably already have most if not all of the dependencies installed on the systems in question.
A custom solution is also possible, but ironically your best reference on how to do that is probably also USBGuard.
| How can I lock down USB Stick access on Linux workstation? |
1,475,746,142,000 |
I know I am able to lock an application using:
sudo chmod a-x /Applications/'Application'.app
but I encountered a problem
while trying to lock an application, like safari, which is built in.
chmod: Unable to change file on /Applications/Safari.app: Operation not permitted
Is there a way to override the permissions?
|
Being unable to change permissions as root on a built-in application or system file on OS X is indicative of System Integrity Protection, a new security feature added in 10.11, which
restricts the root account and limits the actions that the root user can perform on protected parts of OS X.
Protected parts include /System and pre-installed applications, along with the traditional Unix tree.
Any item under a path listed in /System/Library/Sandbox/rootless.conf, or with the com.apple.rootless extended attribute listed by xattr -l, is unmodifiable except by the users listed in the first column of that file, unless SIP has been disabled in recovery mode (which I would advise against, generally).
By nature, this protection includes the root user, and anyone with admin or sudo rights. Only Apple-signed binaries can modify these files.
You can also see this popular reporting article on Ars Technica from when the feature was introduced for more details, including some more about how it works and what the purpose is.
| Lock A Built-in Application? |
1,475,746,142,000 |
There's a file called '/etc/file.conf' on my filesystem.
$ getfacl /etc/file.conf
getfacl: Removing leading '/' from absolute path names
# file: etc/file.conf
# owner: root
# group: root
user::rw-
group::r--
other::r--
I want the my account 'userr' to have write permissions so my Python script can write to it. It's owned by root so my idea was to create a new group and setfacl that to it.
$ sudo groupadd rsnap
$ sudo usermod -a -G rsnap userr
$ id userr
uid=1000(userr) gid=1000(userr) groups=1000(user),27(sudo),1001(rsnap)
$ sudo setfacl -m g:rsnap:rw /etc/file.conf
$ getfacl /etc/file.conf
getfacl: Removing leading '/' from absolute path names
# file: etc/file.conf
# owner: root
# group: root
user::rw-
group::r--
group:rsnap:rw-
mask::rw-
other::r--
However..
$ echo "Test" >> /etc/file.conf
-bash: /etc/file.conf: Permission denied
What have I missed?
|
You modified /etc/rsnapshot.confbut you tested with /etc/file.conf.
You still need to enable the mask via:
setfacl -m m:rw- filename
or
setfacl -m m::rw- filename
depending on the OS - note that this kind of ACLs was never standardized. A related standard proposal from 1993 was withdrawn in 1997.
BTW: I just notice that your mask may have been set already. So you still used the wrong filename.
Problems in this outdated ACL propsal will occur frequently as the standard proposal was never finished and as there was an aggreement that it is not what cutomers like to have.
| ACL group permission still not allowing write permissions |
1,475,746,142,000 |
I'm on OS X and I'm trying to write an interface for for an interpreter, the communication with the interpreter looks like this in PHP:
$f = fopen('mmascript.m', 'w');
fwrite($f, "#!/Applications/mma/Contents/MacOS/MathematicaScript -script\n");
fwrite($f, 'Print[100]');
fclose($f);
chmod('mmascript.m', 0777);
passthru('mmascript.m', $error);
echo $error;
It displays error 127, "command not found". If I cd into that folder and try to run the file I get the error message
bad interpreter: Operation not permitted
If I copy it to another folder, f.e. cp ./mmascript.m ~/Desktop/mmascript.m, it might give the same issue initially but will then magically start working. Since the path to the interpreter is absolute that should mean that the path is correct. Any ideas?
|
Lets add some Debugging Info, like so:
$f = fopen('mmascript.m', 'w');
echo "fopen complete."
fwrite($f, "#!/Applications/mma/Contents/MacOS/MathematicaScript -script\n");
echo "fwrite 1 complete."
fwrite($f, 'Print[100]');
echo "fwrite 2 complete.
fclose($f);
echo "close complete."
chmod('mmascript.m', 0777);
echo "Permissions Successfully Changed."
passthru('mmascript.m', $error);
echo "Passthru Complete."
echo $error;
My gut feeling is that passthru won't echo, because the passthru needs a command followed by your filename.
| Operation not permitted |
1,475,746,142,000 |
I have a plug computer that I want to use as scanner server using sane. It already worked with a different plug, so I know for sure that the scanner and sane are workable together.
If I issue scanimage -L as root I get this output:
device `hpaio:/usb/Deskjet_F300_series?serial=CN73CGJ05504KH' is a Hewlett-Packard Deskjet_F300_series all-in-one
which is what I am expecting, but when I call the command as saned I get this output:
No scanners were identified. [...]
If I call sane-find-scanner as saned it brings up:
found USB scanner (vendor=0x03f0, product=0x5511) at libusb:001:015
Now the interesting part is that the vendor and product is not detected here, but when I do the same as root this is the result:
found USB scanner (vendor=0x03f0 [HP], product=0x5511 [Deskjet F300 series]) at libusb:001:015
So, somehow the root user has access to the list of vendors (and thus is able to detect the scanner) while saned is not. I don't want to run the saned server as root so I need to figure this out.
All settings I did in saned.conf are for the network interaction, but my problem is on the local host, so I skip the config file (but of course can provide it if necessary)
saned groups: saned scanner
I assume that I need to change the privileges of the file where vendor and product are mapped (/etc/sane.d/hp.conf), but that is already readable by sane.
-rw-r--r-- 1 saned scanner 396 Dec 12 2010 hp3900.conf
-rw-r--r-- 1 saned scanner 76 Dec 12 2010 hp4200.conf
-rw-r--r-- 1 saned scanner 238 Dec 12 2010 hp5400.conf
-rw-r--r-- 1 saned scanner 497 Dec 12 2010 hp.conf
-rw-r--r-- 1 saned scanner 22 Dec 12 2010 hpsj5s.conf
Same for /etc/sane.d/dll.d/
-rw-r--r-- 1 saned scanner 38 Dec 10 2013 hplip
Interesting is that neither of these files contain the Deskjet_F300_series information, so maybe there is another file?
Also, while the scanner does have a printing option, I'm not interested in this.
I did read this post, but I would prefer not to do what is described there, because somewhere the information is already present and I would like to access that place, from the saned user.
|
I found that the scanimage -L works after I added saned to the group lp, moments after I posted the question.
I still am interested in the proper answer to this question (where does the information come from). So, this answer is for future visitors who just want to have it fixed.
| sane does not work as saned but as root it does |
1,475,746,142,000 |
I have two three users:
db, nr, ba
All three are members of the group dbp
Node.js is installed in /usr/bin
If I run the command :
/usr/bin/node /home/db/dbb/m/i.js
Then it works fine when I run it as user "ba".
But if I run it as "nr", then it crashes with the error:
Error: EACCES, permission denied './manifest.json'
dbb has permissions: drwxr-s--- db dbp
manifest.json is a file located in the same folder as i.js
The app seems to start and executes until it tries to read manifest.json, at which point it crashes.
EDIT: umask is 027
EDIT: The output of stat ./manifest.json is:
File: `manifest.json'
Size: 251 Blocks: 8 IO Block: 4096 regular file
Device: ca00h/51712d Inode: 2598 Links: 1
Access: (0444/-r--r--r--) Uid: ( 1001/db) Gid: ( 1001/db)
Access: 2014-11-18 18:03:48.297158000 +0000
Modify: 2014-11-18 18:03:37.000000000 +0000
Change: 2014-11-18 18:03:48.298380902 +0000
Birth: -
EDIT: I deleted the user account db, as well as the group dbp. I set the umask to 002. I then recreated only the user account db, and tried to run the command /usr/bin/node /home/db/dbb/m/i.js as db, but had the same error.
This time when I did stat manifest.json, I got the same output:
File: `manifest.json'
Size: 251 Blocks: 8 IO Block: 4096 regular file
Device: ca00h/51712d Inode: 2368 Links: 1
Access: (0444/-r--r--r--) Uid: ( 1001/db) Gid: ( 1001/db)
Access: 2014-11-18 19:08:35.709657000 +0000
Modify: 2014-11-18 18:03:37.000000000 +0000
Change: 2014-11-18 19:08:35.708011027 +0000
Birth: -
|
This file is owned by user db and group db:
Access: (0444/-r--r--r--) Uid: ( 1001/db) Gid: ( 1001/db)
But is world readable (444). The directory hierarchy it is in is not, but it should be readable by group dbp, unless /home/db has non-default permissions. This may be the case since your umask (027) is stricter than normal (002).
Otherwise, it would seem the EACCES error likely occurred because the process tried to open the file for writing.
| What is the cause of this error: Error: EACCES, permission denied |
1,475,746,142,000 |
I'm on a new Centos 7 setup. So far I have logged in via ssh as root:
added a new user
gave user full permission via visudo
added user to the root group (not sure if this is needed)
Logged out and then logged in with the new user. I had already done a few things with the root user, such as install LAMP and add the directory /var/www/public_html/test/
I am able to delete the test directory via SSH, but I am not able to use a SFTP client to do so... when I am using a SFTP client (Transmit for MAC) I get permission denied.
So my question is... how do I give my user permissions that will let me use the SFTP client to complete basic operations such as add/remove/move?
|
You need to setup the SFTP service (it's part of SSH but often times is disabled). Take a look at my answer to this U&L Q&A titled: How can I create an SFTP user in CentOS?.
The key bits are making the following changes to your SSHD setup.
Make these changes to your /etc/ssh/sshd_config file.
Subsystem sftp internal-sftp
## You want to put only certain users (i.e users who belongs to
## sftpusers group) in the chroot jail environment. Add the following
## lines at the end of /etc/ssh/sshd_config
# Match Group sftpusers
# ChrootDirectory /sftp/%u
# ForceCommand internal-sftp
Then restart your SSHD service:
$ sudo service sshd restart
| How to add sftp permission to user/client? |
1,475,746,142,000 |
I have a Linux installation with a default user and an admin user (and root). On startup, the default user is automatically logged in and a particular application is launched. My intention is to prevent the default user from performing any actions that aren't part of the running application. One of the applications actions is to allow some administrative functions which I am thinking would be performed via sudo-ing or ssh-ing as the admin user.
Is it possible to limit the default user the way that I'm describing? I've already setup groups to allow the default user some write access to a database and I've limited their access to the terminal. I've researched chroot-ing and sudo based permissions but I'm not sure which (if any) is the more correct method of permission management or if either is even necessary. Regarding sudo versus ssh for admin access, which is better (or is something else better)? I know there is a lot of Linux permission information out there but I'm having trouble collating it all into a solution that fits this particular problem.
|
Normal users can not do much harm on linux.
But you should check that memory and number of process limits are in place. ulimit -a will show the current settings.
Another thing is the DB access from your java app. That app. should use different access users for different access roles.
Do not use SysDba or comparably privileged accounts in your application.
I see no need for sudo/root in this case.
| How do I limit local user file system access? What is the best method? |
1,393,534,555,000 |
How do I move a file such that the file adopts the target directory permissions?
Surely this is an incredibly common scenario.... any help appreciated.
|
Some sort of wrapper would handle this unusual scenario. The example has been tested as working but takes minimal options (no traditional /bin/mv options can be passed on the command line). Save below to a script and execute it (either with bash script or chmod +x script then run it ./script):
#!/bin/bash
helpusage() {
echo "Usage: $0 targetdir files"
exit
}
getperms() {
/usr/bin/stat --printf="%a" "$1"
}
getowner() {
/usr/bin/stat --printf="%U" "$1"
}
getgroup() {
/usr/bin/stat --printf="%G" "$1"
}
if [[ $# -ge 2 ]]
then
if [[ -d "$1" ]]
then
targetdir=$1
shift
else
helpusage
fi
else
helpusage
fi
td_perms=$(getperms "$targetdir")
td_owner=$(getowner "$targetdir")
td_group=$(getgroup "$targetdir")
/bin/mv --target-directory="$targetdir" "$@" && \
for file in "$@"
do
file="$targetdir/$file"
/bin/chmod "$td_perms" "$file"
/bin/chown "$td_owner":"$td_group" "$file"
done
| How to mv and adopt target directory permissions |
1,393,534,555,000 |
I want to run a program so that it can only create new files and not overwrite existing ones.
Does something like this exist?
$ fsaccess --can read,write --not overwrite --command bash -c 'echo "stuff" > filetim; echo "Woohoo I did it"'
Now if filetim doesn't exist, then the command should run just fine, but if filetim did exist then fsaccess would exit with a message like
Killed child! Command tried to overwrite a file. It does not have permission to do that!
|
If you want a process to be able to create new files but not overwrite pre-existing files, run it as a dedicated user and don't give this user write access anywhere except in some initially-empty directories. That way the program will not have the permission to overwrite any pre-existing file.
If you want to run a program and let it pretend it's overwriting files when it isn't, give it write access only to dedicated directories as above, but in addition you can use a union filesystem such as aufs, funionfs, unionfs-fuse, …, to make another hierarchy appear to the program as well.
If you want to retain all the prior versions of the files overwritten by a process, restrict that process to a copyfs filesystem, which retains all past versions of all files.
If you really need to allow the process to create new files but not to overwrite files, even its own, I don't think you'll find anything preexisting. You could write your own FUSE filesystem.
| Process overwrite access restriction |
1,393,534,555,000 |
I need to login to a Debian server using ssh.exe from Cygwin. I've generated an RSA key and appended it to the authorized_keys file.
Debian is OK, because I was able to use the RSA key using PuTTY to login there. However when I try to login with ssh.exe it says that the password is incorrect. I can't access the ./ssh/ folder from Cygwin.
Update: As I suspected, adding -vvvv shows the following:
debug1: could not open key file '/home/steve/.ssh/id_rsa': Permission denied
The file is there and I can view C:\cygwin\home\steve\.ssh\id_rsa by my file manager.
Update 2:
ls -lA ~/
drwx------+ 1 steve None 0 фев 27 13:20 .ssh
$ ls -l ./.ssh/
ls: невозможно открыть каталог ./.ssh/: Permission denied
How can I fix this?
|
Which .ssh folder can you not access? (You won't be able to see from Cygwin it is on Ubuntu, however you should be able to see it on Ubuntu, from Ubuntu, if that is where it resides). If you generated the RSA key with puttygen, it will not work with Cygwin's ssh.exe because they use different formats for their key file (putty uses a file with extension .ppk which is of a different format).
You can load this ppk file in puttygen and then use Conversions -> Export OpenSSH key to save it in the correct format that ssh.exe can use. If you want to load that key file in Cygwin from your Windows disk drive, you can use the /cygdrive directory to get access to your C: drive (or other drive) where the key resides. You can then use -i to point ssh to it. The other alternative is to use ssh-keygen to generate a new key for Cygwin and add that to Ubuntu's authorized_keys.
Also Cygwin ssh defaults to the username you logged into windows with as the username for the remote host unless you specify it as part of ssh's command arguments.
If it still doesn't work then I'd check what ssh was doing by adding -vvv to your command arguments.
ssh -vvvv -i /cygdrive/c/path/to/my/id_dsa -l username host.address.here
(obviously replacing the correct arguments for -i -l and host.address.here).
| Can't login to remote debian system with RSA key and ssh.exe from Cygwin |
1,393,534,555,000 |
I got a permission denied when I am trying to cd inside a directory.
I could chown it for my user, however I'm wondering if the problem is elsewhere:
The directory in question is an automatic directory added inside /media when I plug my usb external drive. I have read that the points inside /media are automatically removed, so I doubt about the usefulness of my chown.
Is there a way to give access to the user to all the usb things I'm going to plug that will appear inside /media ?
Edit: I rebooted, with the drive unplugged, logged in, then plugged the drive, and then it appears ready to be mounted in PcManFM.
From what I have seen, when it's mounted, there's a point /media/MyDrive_ owned by my user that has been created (/media/MyDrive without the trailing underscore is owned by root). It's when that point has been created, that the drive can no longer be accessed by another user.
So now it's no longer a real problem for me, since the other user was just optionnal in my setup. But it would be nice to know how to get over it when switching between users. Should I unmount external drives any time I log out ?
Edit2: I don't find the webpage, but I have read about a storage user group, can it be related to that ?
|
this is because the partitions were already mounted by another user.
the solution is simply to unmount partition for the other user, then everything is okay.
| Permission rights on automatic directories inside /media |
1,393,534,555,000 |
I have heard that it is good practice to run an executable as a user with a completely different privilege set than the owner of the task. In fact I heard that it is best to run it as a different user with exactly the opposite privilege set. I can understand limiting the privileges of a run time user, but can't this be achieved by the setuid feature?
|
If I understand you correctly, you have an application which is run by a normal user and whose associated files shall not be writeable by normal users to prevent accidental deletion. For this you do not need setuid. All you need to do is something along the lines of:
chown -R root.root /opt/theapp
chmod -R g-w /opt/theapp
chmod -R o-w /opt/theapp
chmod 755 /opt/theapp/bin/theexe
that means you give ownerships of the files to root, disallow all other users to write and allow every user to read and execute but not to write the executable.
| Unix executable file permission vs runtime user's permissions |
1,393,534,555,000 |
Is it possible to set permissions for file to keep it editable but without permission to overwrite?
I mean possibility to edit the file with text editor, but denying any attempt to replace the file by overwriting. The user is root. I know that it is not the common structure of unix file permission, but I am looking for a tricky approach.
I have a package of files, as some of them have been edited/customized from the original version. When updating the package with a new version, I want to replaced any untouched file, but protect the customized files (not to miss edits). Currently, I must do this manually: writing which file has been edited, not to be replaced in new update.
|
Since all packages will try to override the config file completely, you could set the file in append only mode by,
chattr +a bb
Thus you can't do remove/truncate the file, only append it.
But in that case, you will stop package manager from upgrading system.
If you just don't want the package manager to override your customized files, you could hold the package, on debian/ubuntu, you could do:
echo package-name hold | dpkg --set-selections
That way this package will not get upgraded, your files are kept.
| Editing a file without overwrite permission |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.