How to disable/deactivate/archive branches in Perforce - perforce

I have a few applications on Perforce and each application has a few branches. Right now only the latest branch is in actual use, the old ones are there for backtracking and debugging purposes.
Is there a way that I can disable the old branches so that no one can branch/use them?

Removing permissions to them is the best option. Since you want them to remain accessible as a historical reference, but NOT permit new changes, you'll want to remove the "write" level of permission but leave the "read" level:
write user * * -//depot/oldbranch/...
read user * * //depot/oldbranch/...
If only some groups have permissions to these branches in the first place you'd need to be careful of the placement of those lines to make sure you don't accidentally grant "read" permission to the other groups; that might mean doing something more like:
write group * * -//depot/oldbranch/...
read group dev * //depot/oldbranch/...
Or you could use the "=write" syntax instead:
=write group * * -//depot/oldbranch/...
You can also use "=branch" to prevent the old branch from being used as the source for new branches (the "=branch" permission is included with the "read" level unless you explicitly exclude it like this):
=branch group * * -//depot/oldbranch/...
For more on setting up permissions: http://www.perforce.com/perforce/r15.1/manuals/p4sag/chapter.protections.html

Related

Permission need to be removed for multiple users from file

In our organization perforce depot user permissions are managed through group text files. For each branch two type of files are maintained to manage the user permission under perforce version control itself. Both Write and Open permission file sample as follows.
ML_PROJECT_APPLICATION_WRITE.txt - For Write permission:-
# //DEPOT/ABCD/PROJECT/Jerd
# Permission: WRITE
dreac.leoson
ritu.bhangale
makyen
markerikson.s
bernardo.pereira
elitezen
ML_PROJECT_APPLICATION_OPEN.txt - For Open permission:-
# //DEPOT/ABCD/PROJECT/Jerd
# Permission: OPEN
areg.vera
bataklik
jeff.B
michael.chel
muthulakshmi.m
With above format we have multiple text files for each branch and now we need to remove the users permission from text file based on branch name list.
Branch name already available in our group text files. Now what is the best method remove the permission for each user? Is there any script to perform this action? since we have multiple users and branches.
I might suggest turning these text files into groups:
Group: ML_PROJECT_APPLICATION_WRITE
Users:
dreac.leoson
ritu.bhangale
makyen
markerikson.s
bernardo.pereira
elitezen
Group: ML_PROJECT_APPLICATION_OPEN
Users:
areg.vera
bataklik
jeff.B
michael.chel
muthulakshmi.m
and then specifying your protections table in terms of those groups:
Protections:
write group ML_PROJECT_APPLICATION_WRITE * //DEPOT/ABCD/PROJECT/Jerd/...
open group ML_PROJECT_APPLICATION_OPEN * //DEPOT/ABCD/PROJECT/Jerd/...
My recommendation would be to just use Perforce's interface directly rather than having your own file format and writing a script that translates it into Perforce commands, but if you do need to write that script it seems like a pretty straightforward pattern matching exercise.

Puppet: manage the recursiveness of owner/group/mode attributes separately

I need to write a Puppet script to manage the directory /foo/bar such that:
the file mode on /foo/bar is 777, but the permissions of everything within the directory are not managed by Puppet.
the owner/group on /foo/bar and everything within it is baz.
That is, the first requirement is non-recursive, but the second attribute is recursive.
Puppet provides a single recursive attribute, which affects the behavior of owner, group, and mode simultaneously. This means that I cannot specify the desired behavior using a single resource declaration.
I tried using two resource declarations, but then I get the error
Error: Duplicate declaration: File[/foo/bar] is already declared in file /my/puppet/file.pp at line XX; cannot redeclare
Yes, this will not work. Mind that Puppet is not a scripting engine, but a tool to model your desired state.
You will therefor have to decide how you want to manage your directory: As a single file system entry (recurse => false) or a whole tree (recurse => true). In the latter case, Puppet will always manage all properties for which you are passing values.
In your situation, you will likely have to fall back to the workaround of managing the permissions of the directory itself through a different resource, likely an exec resource that calls chmod, independently of the file resource. The latter must not pass a value for mode in this constellation, otherwise the two resources will always work against one another.
It's no ideal, but Puppet is not well equipped to deal with your specific requirements.

permission of knowing a directory empty or not

When I tried to simulate the permission system under Linux, some strange things came about.
I created a directory 'main' by user 'normal', and created directory 'aha' which permission is 700 using root.
so the owner of 'main' is 'normal', if the permission is 755, I can delete 'aha' just using 'normal' user although its owner is root.
but when i put a file in 'aha', everything is changed. I can not remove 'aha' due to there's still a file in it.
so, my question is, since 'aha' is 700 by root, how can 'normal' know it's empty or not?
My further question is : what does read permission of a directory really mean?
Think of a UNIX directory as a drawer of index cards in the library catalog.
In order to know what books there are, you need read permission on the "drawer". In order to create or remove new "books", you need write permissions (which give you ability to put new cards, or remove existing cards from the drawer). In order to "traverse" the directory to a lower level "sub-drawer", you need execute permission on the drawer itself.
If you already know that book /foo/bar/baz exists, you don't need read permissions on /, /foo or /foo/bar, but you do need execute permissions on all of them.
A given book could be referenced by multiple "cards" in the same or separate "drawer" (that's hard links).
A "card" can reference another card (that's symlinks). Symlinks could became "dangling" (if the other card is removed).
When a book is not referenced by any card in any of the drawers, it "evaporates" from the library.
since 'aha' is 700 by root, how can 'normal' know it's empty or not
Well, one way is to try to remove it. If you succeed, it must have been empty. If it was not empty, "normal" can't find out anymore than that, since "normal" can't read the directory, and therefore can't find how many cards are in that "drawer", or what they are called.
Update:
why do you need execute permissions to traverse a directory.
Because that's the definition of the eXecutable bit for directories. Since you can't reasonably execute a directory, that bit would be wasted otherwise. No, the . and .. files have nothing to to do with the execute bit.
very basically a file/dir permission of 700 is not seven hundred but actually
owner = 7
group = 0
everyone = 0
the numbers pertain to a permission level
0 = no permission
1 = allow to execute (run file or access directory)
2 = allow to write (manipulate)
4 = allow to read (see)
you add the permissions levels up to assign more then one permission for example
$ chmod 754 foo
gives full access to the owner (1+2+4), execute 'n' read to the group (1+4), and read to everyone (4) look at
http://www.linuxclues.com/articles/16.htm
http://www.tuxfiles.org/linuxhelp/filepermissions.html
for more info

P4 protect rights for subfolders

I want to make certain folders read-only for the developers while some subfolders in that folder as write also.
For example, consider the folder structure:
Meeting/Jan/DevInfo/
Meeting/Feb/DevInfo/
Meeting/March/DevInfo/
Meeting/April/DevInfo/
Meeting/May/DevInfo/
I want the developers to have read permission to //Meeting/ but write permission to //Meeting/.../DevInfo/...
Can I use the following code?
read group developers * //Meeting/...
write group developers * //Meeting/.../DevInfo/...
I think it should be correct, but visual in P4 shows that the whole structure of //Meeting/ is write-allowed for developers.
Change the write access line to:
write group developers * //Meeting/*/DevInfo/...
The * character means "all files within the Meeting directory, excluding subdirectories".
The ... entry that you had before means "all files and subdirectories under //Meeting", so it overrode the following DevInfo/... section.
Try running the following to check what the protection levels are:
p4 protects //Meeting/...

How can UNIX access control create compromise problems?

My system administrators advice me to be careful when setting access control to files and directories. He gave me an example and I got confused, here it is:
a file with protection mode 644 (octal) contained in a directory with protection mode 730.
so it means:
File: 110 100 100 (owner, group, other: rw- r-- r--)
Directory: 111 011 000 (owner, group, other: rwx -wx ---)
How can file be compromised in this case?
It depends on what you mean by 'compromise' and it depends on who belongs to the group.
The directory permissions are critical. Since members of the group can access the directory ('x') and can modify the directory ('w'), even though they cannot list the directory (no 'r'), it means that if a member of the group knows the name of the file, that person can also remove it because removing a file requires permission to write to the directory - the file permissions are immaterial (even though commands such as 'rm' let you know when you don't have write permission on the file, that is a courtesy, because it doesn't matter to the 'unlink()' system call).
So, a member of your group (or, more precisely, a member of the group to which the directory belongs) can remove the file if they know its name. They can also read the file if they know its name, and they can create a file of the same name if the original is already missing. It appears from the file permissions that being able to read the file is not compromise - you would have denied group read access (and public read access) if that mattered.
Note that although your group members cannot modify the file, because they can delete the file and create a new one with the same name, the result is basically the same as being able to modify the file. One key difference is that you'd know which user did the mischief because that user would own the file. (Well, someone with access to that user ID did the mischief.)
Since the directory can be written to, the file could simply be overwritten with another if the attacker is in the directory owner's group.

Resources