通过 Cygwin(调用 shell 脚本)创建的文件没有正确的 Windows 权限

发布于 2024-11-24 16:33:01 字数 804 浏览 3 评论 0原文

我目前正在目标 Windows Server 2003 计算机上运行 Cygwin,以启动 shell 脚本,该脚本除其他外,还会在光盘上创建一堆文件。但是,创建文件后,我不再有通过 Windows 操作它们的权限。

创建文件时,所有者将设置为“系统”,并且管理员/创建者组/创建者所有者/系统的权限仅设置为“特殊权限”,没有其他权限。 每个人和用户的权限都具有读取和读取权限。执行、列出文件夹内容并读取。

我的问题是我现在无法通过 Windows 删除/修改文件。我希望在我的脚本中内置一些内容(shell 脚本或在 Cygwin 中调用的内容),以允许管理员完全控制文件夹和所有内容。

我当前的解决方法是通过 Cygwin 进行文件修改,但这并不可取。我还使用 setfacl -r -m default:other:rwx 为“用户”组添加写入权限,但它似乎没有递归选项,并且仍然没有给出“完整” 有没有

更好的方法来使用setfacl?我可以使用不同/提升的权限调用 shell 脚本吗?

新创建的目录上的 getfacl 结果:

$ 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

枕梦 2024-12-01 16:33:01

您可以尝试设置 umask:

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

这应该为用户、组和其他人提供对任何新创建的目录的读/写/执行权限。

如果您只想永久修改umask,则可以将其添加到您的.bash_profile


编辑 - 在之前/之后添加 mkdir 的示例umask。

这是在设置 umask 之前创建的目录上 getfacl 的输出:

[/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

这是在创建的目录上 getfacl 的输出我设置后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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文