Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set file permission bits with Perforce

Tags:

perforce

I have a few files that I noticed have the Other bits turned off (e.g., permissions set to 550 when checked-in to Perforce). I want them to be readable and/or executable by everyone. To put it in 'ls -l' parlance, the file's permissions look like this:

Checked-in: -r-xr-x---
Checked-out: -rwxr-x---

I tried setting chmod 555 before doing p4 edit, but Perforce just resets it to 750. Likewise I tried chmod 755 after the file was opened for editing, but when I submit it reverts to 550.

I read the p4 help filetypes documentation and saw nothing that answered this, but I tried +x anyway and it didn't make any difference.

How can I set the Other bits in Perforce?

like image 357
Angelo Babudro Avatar asked Feb 04 '15 16:02

Angelo Babudro


People also ask

What are 644 permissions?

Permissions of 644 mean that the owner of the file has read and write access, while the group members and other users on the system only have read access. For executable files, the equivalent settings would be 700 and 755 which correspond to 600 and 644 except with execution permission.

Who can access a file with permission 444?

444 = (r-- r-- r--): owner/group/others are all only able to read the file. They cannot write to it or execute it.


2 Answers

There are two ways to set file permissions in Perforce:

  1. Set the file permissions before you p4 add the file to Perforce.
  2. Edit the file with the permissions you would like to have i.e:
p4 edit -t text+x some_bash_script.sh

Then Perforce will open the file for edit using the filetype you requested. This document has more information on Perforce filetype options.

like image 186
Ricky Levi Avatar answered Oct 21 '22 23:10

Ricky Levi


The solution was to set the umask (user file-creation mask) so that it does not mask the bits I want to keep -- e.g., "umask 0022".

My umask was "0027" because by default I did not want new files to be world-readable. Most often a file's permissions stay as they are set. If you edit a file, for example, change its permissions, then edit it again, its permission structure is not reset according to your umask, but rather the original is retained.

It appears as if Perforce erases and re-writes the file with every operation. Even if you "p4 edit" a file, then change your umask, and immediately do "p4 revert" without making any modifications to the file Perforce will change the permission bits according to your umask.

like image 24
Angelo Babudro Avatar answered Oct 22 '22 01:10

Angelo Babudro