问题标签 [umask]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
637 浏览

php - 使用 PHP 将文件上传到 FTP - 不会写入服务器

我正在尝试将文件上传到 FTP 服务器。它被 if 语句捕获,该语句指出目录必须是 chmode 777 但是我在 ftp 中手动 chmode 77 并在代码中添加了一个函数。

其次,我想问一下上传过程开始后创建的 .tmp 文件。它们是否上传到 FTP?如果是这样,我是否还需要允许访问 .tmp 文件以及 .mp3 文件?我完全不知道他们在这个过程中的实际用途是什么,所以如果有人能花时间解释一下,那将非常有帮助。

一些变量内容:

这是我用来将文件传递到 FTP 的代码:

感谢您提前提供任何帮助。

0 投票
3 回答
5351 浏览

freebsd - FreeNAS umask / 文件所有者上的传输

安装在 FreeNas 8.3.1 上的传输有点疯狂(不是在监狱里)

一切都很好,除了下载文件的所有权/权限,它们都归root所有并具有掩码:rwxr-sr-x

我尝试将 settings.json 中的 'umask' 从 18 更改为 0(在某处读取),但这无济于事,它似乎被忽略了;我想要的是让任何用户都能够删除这些文件(rw.rw.rw。),或者至少是组,而不仅仅是所有者;我不知道我应该将 umask 更改为什么才能使其正常工作。如果您了解umask,可能真的很容易......

或者,如何更改设置以使所有者是另一个用户,而不是 root;我在启动时作为服务/守护程序启动传输,我尝试更改启动脚本以添加守护程序用户,但它似乎也被忽略了,文件仍然由 root 创建。

非常感谢任何提示!

0 投票
2 回答
2822 浏览

java - 如何从 Java 中获取当前的 umask 值?

我在 unix 机器上运行 java 7 应用程序。有没有办法在纯 java 中获取当前的 umask 值?

在 CI 中会使用umask系统调用的组合,但我认为我不能在 Java 中调用它而不求助于 JNI。还有另一种方法吗?

编辑:这是一个 C 示例(来自 GUN libc 文档):

0 投票
1 回答
1360 浏览

bash - umask 用于额外权限,例如在目录上设置组 ID

如何设置 umask 以使用 set-group-id 标志创建新目录作为默认值?

(我在 CentOs6 上使用 bash)

我试试:umask 5022

bash:umask:5022:八进制数超出范围

或:umask 05022

bash:umask:05022:八进制数超出范围

或者:umask u=rwx,g=srx,o=rx

bash:umask:`s':无效的符号模式字符

最后一个选项不好,因为我们只需要目录的 setgid。

0 投票
1 回答
205 浏览

file-io - 文件创建掩码和umask

我在一本书中阅读了有关文件创建掩码的内容,并遇到了这个问题:

例如,如果掩码的值为 04+02+01=07,那么每当创建文件时,通常由这些值指示的权限将被关闭。因此,在此值生效的情况下,使用以下语句创建的文件:

实际上将被赋予 0640 模式。这意味着文件所有者和与文件关联的组的成员将能够使用该文件,但其他类型的用户将被拒绝任何访问。

我无法理解为什么模式会从 0644 更改为 0640。正在创建的文件的权限是什么?

0 投票
3 回答
28101 浏览

c - 如何在 C 中创建具有特定权限的 Unix 域套接字?

我有一个简单的代码,例如:

我想以原子方式创建具有特定权限的 Unix Domain Socket 文件,例如:0777. 该手册没有说明有关套接字文件权限的umask任何内容。即使,如果umask确实影响套接字文件,那么它也不是一种原子方式 - 在多线程程序中。

我希望,有一种方法可以在不使用umask()调用同步的情况下实现我的目标。

0 投票
4 回答
11366 浏览

apache - How to trace where php5-fpm umask settings are coming from on ubuntu

I'd really appreciate any help in tracking down and diagnosing an umask issue on Ubuntu:

I'm running php5-fpm with Apache via proxy_fcgi. The process is running with a umask of 0022 (confirmed by having PHP send the results of umask() into a file [the result is '18' == 0022]). I'd like to change this to 0002, but can't track down where the umask is coming from.

Apache is set with umask 0002, and as a test, if I disable proxy_fcgi and run my test above, I get a file with u+g having rw access (and the file contents confirm the umask as '2' == 0002).

If I sudo -iu fpmuser and run umask the results are 0002.

System info:

  • PHP: 5.5.3-1ubuntu2.1
  • Apache: 2.4.6
  • Ubuntu: 13.10
  • PHP-PFM is listing using TCP ports (as Unix ports aren't yet working/support)

So far I've tried the following (each followed by a system restart and a retest):

  • adding umask 0002 to the start of /etc/init.d/php5-fpm
  • adding --umask 0002 into the start-stop-daemon calls in /etc/init.d/php5-fpm
  • adding umask 0002 to .profile in the home of the fpm user

Something is clearly adjusting the umask of the php-fpm process - so, how can I begin tracing what is forcing the umask 0022 onto the php-fpm process?

EDIT (1):

  • adjusting the system wide umask via /etc/login.defs (see How to set system wide umask?) affects the umask elsewhere (e.g. comannds via sudo now have a umask of 0002), but still php-fpm creates files with a umask of 0022. Note that I verified that session optional pam_umask.so was also present in /etc/pam.d/common-session-noninteractive and I tested umasks of 002 and 0002.

EDIT (2):

  • I have been able to replicate the issue using nginx and php5-fpm (using unix sockets set to listen mode '0666').
  • I would love to trace where the umask is coming from but I'd settle for some way to force it to what I want.
  • I should add that the first test was done on an Amazon Ubuntu 13.10 image. My tests in 'edit 2' where completed using a copy of the Ubuntu13.10 server ISO setup from scratch in a virtual machine. All installations were completed via apt-get rather than by downloading the source and building.

EDIT (3):

  • I have confirmed I can manipulate the umask manually by either of the following (verified by checking the permissions on the test file created):

    a. In a shell, set a umask then run /usr/sbin/php-fpm from the shell

    b. In a shell, run the following with whatever umask value I like:

    /li>
  • However this exact same command in the /etc/init.d/php5-fpm file fails to adjust the umask when running sudo service php5-fpm stop; sudo service php5-fpm start or at reboot.

0 投票
1 回答
325 浏览

wordpress - UMASK、Virtualmin、WordPress 和 Ubuntu 12.04

我已经使用 DigitalOcean 部署了一个新的 VPS。这是一个标准的 LAMP 堆栈,我在 Virtualmin 中创建了一个新的“虚拟服务器”后正在测试 WordPress 安装,但它的 UMASK 是 022,我需要它是 002。

所以我更新了 /etc/login.defs 第 151 行并重新启动了 Apache,然后创建了一个新的虚拟服务器,但它没有像我预期的那样尊重 UMASK。我错过了什么吗?

0 投票
1 回答
7781 浏览

linux - 用于 sudo 和 apache 的 linux umask

我想让 002 成为所有用户(在 Ubuntu 中)的系统范围的 umask。我设法使用@ehemient 提供的说明为所有普通用户这样做(来自这篇文章,谢谢!)。但是我又遇到了两个问题。

首先,当 sudoing 时,root 用户似乎遵循自己的设置,使用权限 644(而不是 664)制作文件。

其次,apache 用户(www-data)似乎也遵循它自己的设置(与 root 使用的相同?),使用权限 644(而不是 664)制作文件。我不喜欢umask 002输入/etc/apache2/envvars,我宁愿首先更改将 002 umask 分配给 apache 的设置。

我该如何解决最后两个问题?

0 投票
1 回答
708 浏览

perl - 在 PBS-job 上设置 umask

在编写 Perl 脚本以提交 PBS 作业的过程中,我注意到输出文件仅供所有者使用(rw-------)。经过一番研究,我发现您可以放入#PBS -W umask=002作业脚本以使其他人可以访问。

珀尔:

此 Perlscript 创建以下作业:

是否有可能将指示的行 ( <---) 从 Perlscript 传递给作业?