MaxBk
MaxBk

Reputation: 157

Perl - Perforce new workspace Trigger: Create a directory with same permissions as parent directory or as Perforce would give

What we want to achieve is to add a local file to each new workspace that is created.
What I currently do is running a script on the trigger of "form-commit client".

That trigger contains the path on the Client's machine where the workspace should be created but the problem occurs when the user tries to create the workspace on a network drive.

What happens is that the file and the directory are created but only with permissions to "Root" since they both didn't exist before so after the trigger's script is completed perforce can't push the source codes to the directory because it doesn't have permissions(and the user can't edit the directory and the file because of the same reason).

There are two directions from my point of view to solve this problem:
1) make sure that the perl script "mkdir" command creates the directory with the same permissions of the parent directory.(how can i do it?) Irelevant, I asked it in another question on stack overflow.

2) Create the file that the trigger is for only after the "pull" command is done by perforce and the workspace directory was created by perforce(What's the trigger for that)

Thanks in advance,
Max.

Edit: (I was wrong aboth the last bullets, it dosen't work as I thoguht it does)

I did the steps that are suggest in the comment and it doesn't work out.

I suspect that all of this is directly related to perforce service user, so here is the thing:
1) The network drive is mapped in a way that only I can write to my user's folder(+ network admins).

2) The perforce trigger pearl script runs on the perforce server(with admin user I suspect.)

3) When the script creates the folder it gives permissions to me(windows domain user) + UnixPermUid\root + UnixPermGid\root which im not part of those groups.

4) When I do chmod (07777, $dir) or die "couldn't chmod $!"; nothing happens(nor error or permissions given)

5) I can't delete the folder from "Windows explorer" or with a trigger that deletes it.

6) The next steps + the trigger are working good:

Edit 2: Any ideas for question number 2?

2) Create the file that the trigger is for only after the "pull" command is done by perforce and the workspace directory was created by perforce(What's the trigger for that)

Upvotes: 0

Views: 147

Answers (1)

MaxBk
MaxBk

Reputation: 157

The solution for it was to call icacls system command to grant permissions to the user who created the work space.

$error = system("icacls $ToWriteToDir /grant domain\\user:(OI)(CI)F /T");

The code above adds full recursive permissions to the user who triggered the script(created a new workspace) to the directory on the network drive.

I posted a related more general question here. I decided to separate into two questions in case that someone will find a more relevant solution for the use case of perforce, or general solution for any kind of service.

Upvotes: 0

Related Questions