Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Files created through Cygwin (calling a shell script) don't have correct Windows permissions

I am currently running Cygwin on a target Windows Server 2003 machine to fire off a shell script that, among other things, creates a bunch of files on disc. However after the files are created I no longer have permissions to manipulate them through Windows.

When the files are created the owner is getting set to 'SYSTEM' and the permissions for Administrators/Creator Group/Creator Owner/system are set to only 'special permissions' and nothing else. The permissions for Everyone and Users have Read & Execute, List folder contents and Read.

My problem is that I cannot delete/modify the files now through Windows. I would prefer to have something built into my scripts (either the shell script or something to call in Cygwin) that would allow Administrators full control on the folder and all contents.

My current workaround has been to either do file modifications through Cygwin but this is not preferable. I have also used setfacl -r -m default:other:rwx to add write permissions for the 'Users' group but it doesn't appear to have a recursive option and still doesn't give 'full control'

Is there a better way to use setfacl? Can I call the shell script using different/elevated permissions?

Results of getfacl on a newly created directory:

$ getfacl Directory/
# file: Directory/
# owner: SYSTEM
# group: root
user::rwx
group::r-x
group:Users:rwx
mask:rwx
other:r-x
default:user::rwx
default:group::r-x
default:group:Users:rwx
default:mask:rwx
default:other:r-x
like image 898
chrisst Avatar asked Jul 18 '11 23:07

chrisst


People also ask

How do I run a bash file in Cygwin?

into a CygWin terminal type the command ls /bin/bash.exe : it list the executable for bash. open a windows CMD and type the command dir C:\cygwin\bin\bash.exe : it list the executable for bash.

Does Cygwin use bash?

The Cygwin installation creates a Bash shell along with a UNIX environment by which you can compile and run UNIX-like programs. Using this one can even create an emulated X server on your windows box and run UNIX-like GUI software tools.


1 Answers

You can try setting umask:

umask u=rwx,g=rwx,o=rwx

That should give user, group, and other read/write/execute on any newly created dirs.

If you only want the modified umask permanently, you can add it to your .bash_profile


Edit - Added example of mkdir before/after umask.

Here's the output of getfacl on a directory created before I set umask:

[/cygdrive/c/Documents and Settings/NOYB/Desktop]
==> getfacl test_wo_umask/
# file: test_wo_umask/
# owner: NOYB
# group: Domain Users
user::rwx
group::r-x
group:root:rwx
group:SYSTEM:rwx
mask:rwx
other:r-x
default:user::rwx
default:user:NOYB:rwx
default:group::r-x
default:group:root:rwx
default:group:SYSTEM:rwx
default:mask:rwx
default:other:r-x

Here's the output of getfacl on a directory created after I set umask:

[/cygdrive/c/Documents and Settings/NOYB/Desktop]
==> getfacl test_w_umask/
# file: test_w_umask/
# owner: NOYB
# group: Domain Users
user::rwx
group::rwx
group:root:rwx
group:SYSTEM:rwx
mask:rwx
other:rwx
default:user::rwx
default:user:NOYB:rwx
default:group::rwx
default:group:root:rwx
default:group:SYSTEM:rwx
default:mask:rwx
default:other:rwx
like image 86
Daniel Haley Avatar answered Sep 28 '22 07:09

Daniel Haley